#Dash scripting pain
1 messages · Page 1 of 1 (latest)
** You are now Level 2! **
coding in arial
in what?
What's that colors
Coding in old egypt Manuscript
Debug lik add some prints
Unsure if this is like pseudo code
But its dir.Magnitude
So if dir.Magnitude == 0 then set dir to vector3.new(1,0,0)
kinda unrelated but the default dash should probably be up or where your character is facing cus rn its always right which is kinda weird if you're facing left
Yeah it just i kinda wanna make a 8 direction dash like
Up right left down ect
So i kinda have 0 how to make a wrap around (btw this is paired with a 2d script
Imma show u
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
repeat
wait()
until Player.Character
local Player = Player.Character
local HumanoidRootPart = Player.HumanoidRootPart
local Positioner = Instance.new("BodyPosition", HumanoidRootPart)
Positioner.MaxForce = Vector3.new(0, 0, math.huge)
Positioner.Position = Vector3.new(0, 0,HumanoidRootPart.Position.Z)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = Player.HumanoidRootPart
game:GetService("RunService").RenderStepped:connect(function()
Camera.CFrame = CFrame.new(HumanoidRootPart.CFrame.X, HumanoidRootPart.CFrame.Y, HumanoidRootPart.CFrame.Z + 30)
Camera.FieldOfView = 50
end)
The 2d camera makes the player move left and right
But the player can still move in other directions but i kinda cant fix that
Edit that and put three ``` in front and end please
This will put it in a code structure
Oh ok
local test = hi
You can add a lua at the end of the first three `
To make it colored
local someVariable = "hi" ```
local Player = game.Players.LocalPlayer
repeat
wait()
until Player.Character
local Player = Player.Character
local HumanoidRootPart = Player.HumanoidRootPart
local Positioner = Instance.new("BodyPosition", HumanoidRootPart)
Positioner.MaxForce = Vector3.new(0, 0, math.huge)
Positioner.Position = Vector3.new(0, 0,HumanoidRootPart.Position.Z)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = Player.HumanoidRootPart
game:GetService("RunService").RenderStepped:connect(function()
Camera.CFrame = CFrame.new(HumanoidRootPart.CFrame.X, HumanoidRootPart.CFrame.Y, HumanoidRootPart.CFrame.Z + 30)
Camera.FieldOfView = 50
end) ```
Thats the camera
And the script is to large to put into a single message so gimma asec
Please dont LOL
Don't need your whole game in a message, just need where the issue is. Try and pin point somewhere, but again I think your magnitude is wrong if thats what the actual code looks like
Ok
It would make sense because that one makes it default right
Hmmm
K lemme check
if dir.Magnitude == 0 then
dir = Vector3.new(1, 0, 0) -- right
end```
Just checking is this have any problems.
if UIS.TouchEnabled then
local playerGui = player:WaitForChild("PlayerGui")
local joystick = playerGui:FindFirstChild("Joystick") -- replace with your joystick GUI
if joystick then
local thumb = joystick:FindFirstChild("Thumb")
local outer = joystick:FindFirstChild("Outer")
if thumb and outer then
local offsetX = thumb.Position.X.Offset - outer.Position.X.Offset
local offsetY = thumb.Position.Y.Offset - outer.Position.Y.Offset
local mag = math.sqrt(offsetX*offsetX + offsetY*offsetY)
if mag > 0 then
dir = Vector3.new(offsetX/mag, offsetY/mag, 0)
end
end
end
end
-- Default direction if no input
if dir.Magnitude == 0 then
dir = Vector3.new(1, 0, 0) -- right
end
return dir.Unit
end
And thats meant to make the dash go in the direction of the mobile joystick
Ah seems like you have the magnitude correct in the code
K thank goodness
Does this work with keyboard?
Yeah lemme get the keyboard part
Print your dir right before you return and see what it says, if its whats its suppose to be, then its not that causing issues
if UIS:IsKeyDown(Enum.KeyCode.W) then dir = dir + Vector3.new(0, 1, 0) end
if UIS:IsKeyDown(Enum.KeyCode.S) then dir = dir + Vector3.new(0, -1, 0) end
if UIS:IsKeyDown(Enum.KeyCode.A) then dir = dir + Vector3.new(-1, 0, 0) end
if UIS:IsKeyDown(Enum.KeyCode.D) then dir = dir + Vector3.new(1, 0, 0) end
Oh!
Thx!
I gtg now but i will try that later!