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

how to make a humanoid animate on touch?

Asked by 3 years ago

Ive got it to work when being touched, but it only works once, any suggestions?

local db = true
local animation = script:WaitForChild('Animation')
local humanoid = script.Parent:WaitForChild('Humanoid')
local anim = humanoid:LoadAnimation(animation)


script.Parent.Crate.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            anim:Play()
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Your settings db to false and never setting it to true again thats the reason.

Also, instead of doing this

if db == true then
    --do something
end

Do this

if db then
    --do something
end
0
Ah okay, I'll try that.. Thanks! antazma 8 — 3y
0
and if u want to check if its false do: if not db then CaioAlpaca 342 — 3y
0
awesome! Thanks for the help :) antazma 8 — 3y
Ad

Answer this question