I made a dash script, but it doesn’t seem to move my Character.
Script:
-- // Constants \\ --
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
-- [ LocalPlayer ] --
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)
-- // Variables \\ --
local KeyCode = Enum.KeyCode
local Keys = {
[KeyCode.W] = time();
[KeyCode.A] = time();
[KeyCode.S] = time();
[KeyCode.D] = time();
}
local BodyPosition = Instance.new("BodyPosition")
-- // Event Listeners \\ --
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if GameProcessedEvent then return end
local InputKey = Input.KeyCode
local KeyTime = Keys[InputKey]
if KeyTime then
if time() - KeyTime < 0.25 then
BodyPosition.Parent = HumanoidRootPart
if InputKey == KeyCode.W then
BodyPosition.Position = HumanoidRootPart.Position + (HumanoidRootPart.CFrame.LookVector.Unit * 100)
elseif InputKey == KeyCode.A then
BodyPosition.Position = HumanoidRootPart.Position + (HumanoidRootPart.CFrame.RightVector.Unit * -100)
elseif InputKey == KeyCode.S then
BodyPosition.Position = HumanoidRootPart.Position + (HumanoidRootPart.CFrame.LookVector.Unit * -100)
elseif InputKey == KeyCode.D then
BodyPosition.Position = HumanoidRootPart.Position + (HumanoidRootPart.CFrame.RightVector.Unit * 100)
end
wait(1)
BodyPosition.Parent = nil
end
Keys[InputKey] = time()
end
end)
-- // Actions \\ --
BodyPosition.D = 50
BodyPosition.MaxForce = Vector3.new(1000, 1000, 100)
BodyPosition.P = 1000