I want to make a dashing script that When you Press WW, or AA, or DD for example the movement keys twice you’d dash in those directions. Dont have an animation yt I just went them to move for now. Any help appreciated.
Userinputservice or context action service is what u can use
Yea I know about that stuff. I just dont know How I’d actually get the player to move.
You can get the player to move by instancing a “BodyVelocity” into their character. I most people put it in the HumanoidRootPart. Then changing the MaxForce and Velocity. The direction is done by the Velocity, which you will need to calculate.
Yup im trying that tell me if you think its going good so far, what should I change.
Also how would I have it respond to me pressing W twice, and not just once.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local UIP = game:GetService("UserInputService")
local Debounce = false
UIP.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode.w then
if not Debounce then Debounce = true
wait(1)
Debounce = false
else
Character.HumanoidRootPart.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 50
end
end
end)
(post deleted by author) ᅟ ᅟ ᅟ
I’m fairly new to scripting so what you described above is a bit complicated for me, Mind helping me out with that?
You could use tick() to respond to pressing W twice.
Example:
- One tick() as a variable outside the function
local var = tick() - Another one checking like this
Input.KeyCode == Enum.KeyCode.w and tick() - var < 0.175I find 0.175 somewhat of a good intermission.
Use a value that is set to true upon clicking and then after 1 second set it to false if the variable is true when clicking then the plsyer had already clicked the button before and by that you can detect double click. Then just make it’s walk speed higher and then set it back to normal or make a function that moves the player to a certain direction in relation to the characters heading and then call the function upon double click
Nothing happens, I dont get it lol. according to what I searched online Tick() checks time in second between it and something?
Here’s something I found that could help you out with that I guess: Link
(post deleted by author) ᅟ ᅟ ᅟ
Oh wow thats incredible. I’ll work on understanding it later, I greatly appreciate your help :)!
I followed that tutorial and got this
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local UIP = game:GetService("UserInputService")
local LastTime = tick()
local Debounce = false
UIP.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode.W then
local now = tick()
local difference = (now - LastTime)
if difference <= 1 then
if not Debounce then Debounce = true
wait(1)
Debounce = false
else
Character.HumanoidRootPart.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 200
end
end
end
end)
no errors, bt still not working. This is in a local script btw.
u see any issues?
Try this one
local t = 0
local dif = tick() - t
UIP.InputBegan:Connect(function(Input, IsTyping)
if not IsTyping then
if Input.KeyCode == Enum.KeyCode.W then
dif = tick() - t
if dif < 1 then -- Tapped twice under one second
print("Test") -- Prints "Test" if tapped twice under a second
t = 0
return
end
t = tick()
end
end
end)
I just tried it out and it worked great! TY
Do you know what I’d have to do to have it also work like backwards, left , and right.
With DD, AA, and SS of course.
I know we’d change i.Position = (root.CFrame*Vector3.new(0,0,-Dash_Normal))
and Input, but idk how to make it a seperate one for each.
(post deleted by author) ᅟ ᅟ ᅟ
Ty I appreciate your knowledge, I’m gonna study this all later so I can learn to do it on my own lol
(post deleted by author) ᅟ ᅟ ᅟ
How do you make it not glitch you and fling you when you dash into a wall?