Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

2 comments

0

I have given an answer.

0

Srsly?

1 answer

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)

3 comments

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

0

Try 1? They will be able to move yet very little.

0

oh yeah i can do that

This discussion is preserved as it was. New answers, comments, and votes are closed.