hello I’m trying to make a player play an animation 24/7 but when they say stop in chat I want it to stop the animation from playing. I have this script to do it however its not working (NO ERROR)
local Stop= false
local humanoid = game.Players.LocalPlayer.Character.Humanoid
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.Parent = humanoid
animation.AnimationId = "http://www.roblox.com/asset/?id=507770239"
local PlayThis = animator:LoadAnimation(animation)
game.Players.LocalPlayer.Chatted:Connect(function(msg)
if string.lower(msg) == "stop" then
Stop = true
print('stop this shit bruh')
end
while Stop == false do
PlayThis:Play()
end
end)
If you want it for walking/running try as a script in ServerScriptService, it’s only for R15 though.
local Players = game:GetService("Players")
local runAnimation = "http://www.roblox.com/asset/?id=507770239"
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local animateScript = character:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = runAnimation
end
local function onPlayerAdded(player)
player.CharacterAppearanceLoaded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
If you only want it to start at the beginning, and then end it with saying “stop” in chat, this will work. Make sure you save it into StarterPlayerScripts as a local script.
Local script
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Parent = humanoid
animation.AnimationId = "rbxassetid://10318640511" --use "rbxassetid://" and insert your animation id after that two slashes
local anim = humanoid:LoadAnimation(animation)
anim:Play()
game.Players.LocalPlayer.Chatted:Connect(function(msg)
if string.lower(msg) == "stop" then
anim:Stop()
end
end)
Note: Animation wont work if you do not own them, or if they are made for different avatar type (for example you use R6 but animation is for R15).