Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

[SOLVED] How to disable player's movement?(wait() did the trick)

Asked by 2 months ago
Edited 2 months ago
UIS = game:GetService("UserInputService")
plr = game.Players.LocalPlayer
ctr = plr.Character or plr.CharacterAdded:Wait()
hum = ctr:WaitForChild('Humanoid')
an = Instance.new("Animation")
an.AnimationId = "https://www.roblox.com/asset?id=".."2695066337"--id
antrack = hum:LoadAnimation(an)
db = true
strength = plr:WaitForChild("Stats"):WaitForChild("Strength")
UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T and db == true then

        db = false
        local speed = hum.WalkSpeed
        strength.Value = strength.Value + 10
        antrack:Play()
        wait(2)
        speed = nil
        db = true
    end
end)

I've made this script and I've tried anchoring humanoidrootpart and the player can still move. I made the walkspeed and jump power 0 but the animation just stopped working or if you don't get it the animation only partly works by just rotating a slightly bit then going back to normal

My goal: Make the player do the animation and stop moving or jumping when clicked t.

0
I have given an answer. WideSteal321 451 — 2mo
0
Srsly? WideSteal321 451 — 2mo

1 answer

Log in to vote
2
Answered by 2 months ago
Edited 2 months ago

Try this! (Please read what I have said after this script)

EDITED

UIS = game:GetService("UserInputService")

an = Instance.new("Animation")
an.AnimationId = "https://www.roblox.com/asset?id=".."2695066337"--id
antrack = hum:LoadAnimation(an)
db = true
game.Players.PlayerAdded:Connect(function(plr)--// Player added
    plr.CharacterAdded:Connect(function(char) --// Character added

strength = plr:WaitForChild("Stats"):WaitForChild("Strength")
UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T and db == true then

        db = false
        strength.Value = strength.Value + 10
        antrack:Play()
        wait(2)
        char.Humanoid.WalkSpeed = 1--// We are changing Walkspeed to 1
        char.Humanoid.JumpPower =1 --// We are changing JumpPower to 1 
        db = true
    end
end)

I have edited your script anything broken please tell me in comments

If I cannot help further please use this to help you make it yourself (or if no-one else helps or their answers don't work):

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)

 char.Humanoid.JumpPower = 1
char.Humanoid.WalkSpeed = 1

end)
end)
0
ok i do get u and I've tried this before. In my question I clearly state i made them both 0 but it didn't work. What I meant by that is that when I do a push up while im walking the push up animation just breaks off HappyTimIsHim 164 — 2mo
0
Try 1? They will be able to move yet very little. WideSteal321 451 — 2mo
0
oh yeah i can do that HappyTimIsHim 164 — 2mo
Ad

Answer this question