Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 1 year ago
Edited 1 year ago

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

Log in to vote
0
Answered by
ryanzhzh 128
1 year ago

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)
0
ez on line 08 in your script oXDestroyerXo 28 — 1y
0
adding references between yours and mine, I added an animator to the humanoid and came up with this oXDestroyerXo 28 — 1y
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 oXDestroyerXo 28 — 1y
0
changed post to show newer code oXDestroyerXo 28 — 1y
0
sorry for extremely bad post ryanzhzh 128 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

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

Answer this question