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

I've made a script for animating a turtle, why is my script not working?

Ive made a local script with the code in it, with the animation parented to it, I am trying to animate a turtle with a humanoid in it and it's rigged with the animation ready to go.

local window = game.Workspace.window
local animation = script.Animation
local humanoid = game.Workspace.Turtle.Humanoid
local ez = humanoid.Animator:LoadAnimation(animation)
local debounce = false
local function clicked()
	if not debounce then
		humanoid:WaitForChild("Animator"):LoadAnimation(animation)
		wait(2)
		animation:Play()
		print("hello world!")
		wait(2.04)
		window:Destroy()
		debounce = true
	end
end
game.Workspace.Turtle.Button.Touched:Connect(clicked)

this gives me no print message either, so im pretty stumped I have no clue yet what making a function local or not local does, but I've tried both to no avail

--updated code to match what I thought, added animator to humanoid aswell.

2 answers

✓ Accepted answer

DEPRECATED ALERT: don't use Humanoid:LoadAnimation use Humanoid.Animator:LoadAnimation as of here: https://devforum.roblox.com/t/deprecating-loadanimation-on-humanoid-and-animationcontroller/857129

Off of that now, why would you dupe this for nothing tho? local ez = humanoid:LoadAnimation(animation) line 4 humanoid:LoadAnimation(animation) line 8

Fixed code:

local window = game.Workspace.window
local animation = script.Animation
local humanoid = game.Workspace.Turtle.Humanoid
local debounce = false
function clicked()
    if not debounce then
        humanoid:WaitForChild("Animator"):LoadAnimation(animation)
        wait(2)
        ez:Play()
        print("hello world!")
        wait(2.04)
        window:Destroy()
        debounce = true
    end
end
game.Workspace.Turtle.Button.Touched:Connect(clicked)

5 comments

0

ez on line 08 in your script

0

adding references between yours and mine, I added an animator to the humanoid and came up with this

0

local window = game.Workspace.window local animation = script.Animation local humanoid = game.Workspace.Turtle.Humanoid local ez = humanoid.Animator:LoadAnimation(animation) local debounce = false local function clicked() if not debounce then humanoid:WaitForChild("Animator"):LoadAnimation(animation) wait(2) animation:Play() print("hello world!") wait(2.04) window:Destroy() debounce

0

changed post to show newer code

0

sorry for extremely bad post

I just need to use my own knowledge instead of using a tutorial. so I have gotten this to work.

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