Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local p = game.Players.LocalPlayer
- local c = game.Workspace:WaitForChild(p.Name)
- local ips = game:GetService("UserInputService")
- local w,a,s,d,j,ch = 0,0,0,0,0,0
- local canjump = true
- local jumped = false
- local cancrouch = true
- local hum = c.Humanoid
- local playing = false
- local animfold = c:WaitForChild("anim")
- ips.InputBegan:connect(function(inp)
- if inp.KeyCode == Enum.KeyCode.W or inp.KeyCode == Enum.KeyCode.Up then
- w = 1
- end
- if inp.KeyCode == Enum.KeyCode.A or inp.KeyCode == Enum.KeyCode.Left then
- a = 1
- end
- if inp.KeyCode == Enum.KeyCode.S or inp.KeyCode == Enum.KeyCode.Down then
- s = 1
- end
- if inp.KeyCode == Enum.KeyCode.D or inp.KeyCode == Enum.KeyCode.Right then
- d = 1
- end
- if inp.KeyCode == Enum.KeyCode.Space or inp.KeyCode == Enum.KeyCode.ButtonA then
- j = 1
- end
- if inp.KeyCode == Enum.KeyCode.LeftShift or inp.KeyCode == Enum.KeyCode.ButtonR2 then
- ch = 1
- end
- print(w, a, s, d)
- end)
- ips.InputEnded:connect(function(inp)
- if inp.KeyCode == Enum.KeyCode.W or inp.KeyCode == Enum.KeyCode.Up then
- w = 0
- end
- if inp.KeyCode == Enum.KeyCode.A or inp.KeyCode == Enum.KeyCode.Left then
- a = 0
- end
- if inp.KeyCode == Enum.KeyCode.S or inp.KeyCode == Enum.KeyCode.Down then
- s = 0
- end
- if inp.KeyCode == Enum.KeyCode.D or inp.KeyCode == Enum.KeyCode.Right then
- d = 0
- end
- if inp.KeyCode == Enum.KeyCode.Space or inp.KeyCode == Enum.KeyCode.ButtonA then
- j = 0
- end
- if inp.KeyCode == Enum.KeyCode.LeftShift or inp.KeyCode == Enum.KeyCode.ButtonR2 then
- ch = 0
- end
- print(w, a, s, d)
- end)
- local walk = animfold.walk
- local wa = hum:LoadAnimation(walk)
- game:GetService("RunService").RenderStepped:connect(function()
- if w == 1 or a == 1 or s == 1 or d == 1 then
- if not playing then
- if walk then
- wa:Play()
- playing = true
- end
- end
- wait()
- end
- if w == 0 and a == 0 and s == 0 and d == 0 then
- if playing then
- wa:Stop()
- playing = false
- end
- wait()
- end
- if j == 1 then
- local ja = animfold.ju
- local ju = hum:LoadAnimation(ja)
- ju:Play()
- wait(0.3)
- ju:Stop()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement