Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Humanoid = script.Parent:WaitForChild("Humanoid")
- local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
- local w = script:WaitForChild("w")
- local s = script:WaitForChild("s")
- local a = script:WaitForChild("a")
- local d = script:WaitForChild("d")
- local playw = Humanoid:LoadAnimation(w)
- local plays = Humanoid:LoadAnimation(s)
- local playa = Humanoid:LoadAnimation(a)
- local playd = Humanoid:LoadAnimation(d)
- local uis = game:GetService("UserInputService")
- local keys = {
- W = false,
- A = false,
- S = false,
- D = false
- }
- Humanoid.Running:Connect(function(speed)
- if speed > .5 then
- if keys.W == true then
- playw:Play()
- if plays.IsPlaying == true or playa.IsPlaying == true or playd.IsPlaying == true then
- plays:Stop()
- playa:Stop()
- playd:Stop()
- else
- end
- end
- if keys.S == true then
- plays:Play()
- if playw.IsPlaying == true or playa.IsPlaying == true or playd.IsPlaying == true then
- playw:Stop()
- playa:Stop()
- playd:Stop()
- else
- end
- end
- if keys.A == true then
- playa:Play()
- if plays.IsPlaying == true or playw.IsPlaying == true or playd.IsPlaying == true then
- plays:Stop()
- playw:Stop()
- playd:Stop()
- else
- end
- end
- if keys.D == true then
- playd:Play()
- if plays.IsPlaying == true or playa.IsPlaying == true or playw.IsPlaying == true then
- plays:Stop()
- playa:Stop()
- playd:Stop()
- else
- end
- end
- end
- end)
- uis.InputBegan:Connect(function(input, processed)
- if keys.W and not processed then
- keys.W = true
- elseif keys.S and not processed then
- keys.S = true
- elseif keys.A and not processed then
- keys.A = true
- elseif keys.D and not processed then
- keys.D = true
- end
- end)
- uis.InputEnded:Connect(function(input, bool)
- if keys.W then
- keys.W = false
- elseif keys.A then --do the other keys
- keys.A = false
- elseif keys.S then
- keys.S = false
- elseif keys.D then
- keys.D = false
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement