I need the player to move backwards from the way there facing? But this script doesn't work, any fix's?
[Short] Local Script:
for i = 1,14 do
wait(0.01)
local x = game.Workspace[Player.Name].HumanoidRootPart.Position.X
local y = game.Workspace[Player.Name].HumanoidRootPart.Position.Y
local z = game.Workspace[Player.Name].HumanoidRootPart.Position.Z
wait(0.01)
game.Workspace[Player.Name].HumanoidRootPart.CFrame = CFrame.new(Vector3.new(x,y,z +0.5))
end
[Full] Local Script:
wait(3)
--Varibles
local InputService = game:GetService("UserInputService")
local timestamp = tick()
local doubleClickKey = Enum.KeyCode.S
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
--Function
local function doublePress()
--Walkspeed
game.Workspace[Player.Name].Humanoid.WalkSpeed = 0
wait(0.01)
--Animation
local Animation = Instance.new("Animation") -- create a new animation object
Animation.AnimationId = "rbxassetid://2554941606"
local Track = Humanoid:LoadAnimation(Animation)
Track:Play()
--MovePlayer
for i = 1,14 do
wait(0.01)
local x = game.Workspace[Player.Name].HumanoidRootPart.Position.X
local y = game.Workspace[Player.Name].HumanoidRootPart.Position.Y
local z = game.Workspace[Player.Name].HumanoidRootPart.Position.Z
wait(0.01)
game.Workspace[Player.Name].HumanoidRootPart.CFrame = CFrame.new(Vector3.new(x,y,z +0.5))
end
Track:Play()
for i = 1,14 do
wait(0.01)
local x = game.Workspace[Player.Name].HumanoidRootPart.Position.X
local y = game.Workspace[Player.Name].HumanoidRootPart.Position.Y
local z = game.Workspace[Player.Name].HumanoidRootPart.Position.Z
wait(0.01)
game.Workspace[Player.Name].HumanoidRootPart.CFrame = CFrame.new(Vector3.new(x,y,z +0.5))
end
game.Workspace[Player.Name].Humanoid.WalkSpeed = 16
end
--Function2
InputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == doubleClickKey and not processed then
-- Same logic
if tick() - timestamp <= 0.2 then
doublePress()
else
timestamp = tick()
end
end
end)

3 comments
you spelled variable wrong
^ Has nothing to do with the question.
What exactly is the mechanic you're trying to achieve? You could instead use a BodyMover to push the character back a distance.