So, this script isn't finished yet, but I'm trying to make a dash script so that whenever you double-click w, a, s, or d, it does a dash animation, and launches you in a direction based on which key you pressed. It makes the character jump, but the only thing launching it forward, is me pressing w when I'm double clicking.
Server:
local repStorage = game.ReplicatedStorage local dashingEvent = repStorage:WaitForChild("Dashing") dashingEvent.OnServerEvent:Connect(function(player,key) local char = game.Workspace[player.Name] local humanoid = char.Humanoid local rootPart = char:WaitForChild("HumanoidRootPart") if key == "w" then humanoid.Jump = true -- It does this, so I know that this if event isn't just ignored. rootPart.Velocity = rootPart.CFrame.lookVector * 100 -- This should push the player's character forward, right? elseif key == "a" then -- There's nothing here because, once again, it's not finished yet. elseif key == "s" then elseif key == "d" then end end)
Client:
-- This script seems to work just fine, but I decided to post it just in case the problem lies in how I fired the server or something weird like that. local player = game.Players.LocalPlayer local char = player.Character local mouse = player:GetMouse() local clickCount1 = 0 local clickCount2 = 0 local clickCount3 = 0 local clickCount4 = 0 local doubleClickCooldown = 0.2 local db = false local dashCooldown = 1 local repStorage = game.ReplicatedStorage local dashingEvent = repStorage:WaitForChild("Dashing") mouse.KeyDown:Connect(function(key) if key == "w" and db == false then clickCount1 = clickCount1 + 1 if clickCount1 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount1 = 0 elseif key == "a"and db == false then clickCount2 = clickCount2 + 1 if clickCount2 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount2 = 0 elseif key == "d" and db == false then clickCount3 = clickCount3 + 1 if clickCount3 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount3 = 0 elseif key == "s" and db == false then clickCount4 = clickCount4 + 1 if clickCount4 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount4 = 0 end end)
Any help is appreciated!
You can try to use the rootPart.Velocity = rootPart.CFrame.lookVector * 100
in LocalScript
here is the fixed script:
-- This script seems to work just fine, but I decided to post it just in case the problem lies in how I fired the server or something weird like that. local player = game.Players.LocalPlayer local char = player.Character local mouse = player:GetMouse() local clickCount1 = 0 local clickCount2 = 0 local clickCount3 = 0 local clickCount4 = 0 local doubleClickCooldown = 0.2 local db = false local dashCooldown = 1 local repStorage = game.ReplicatedStorage local dashingEvent = repStorage:WaitForChild("Dashing") mouse.KeyDown:Connect(function(key) if key == "w" and db == false then clickCount1 = clickCount1 + 1 if clickCount1 >= 2 then dashingEvent:FireServer(key) local rootPart = char:WaitForChild("HumanoidRootPart") rootPart.Velocity = rootPart.CFrame.lookVector * 100 db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount1 = 0 elseif key == "a"and db == false then clickCount2 = clickCount2 + 1 if clickCount2 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount2 = 0 elseif key == "d" and db == false then clickCount3 = clickCount3 + 1 if clickCount3 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount3 = 0 elseif key == "s" and db == false then clickCount4 = clickCount4 + 1 if clickCount4 >= 2 then dashingEvent:FireServer(key) db = true wait(dashCooldown) db = false end wait(doubleClickCooldown) clickCount4 = 0 end end)