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

How to have different sitting animations?

Asked by 4 years ago

I had 2 IDs in and yet it's not playing the other one and sticking to one ID only.

local Chair = script.Parent
local AnimationIsPlaying 

Assets = {4295096597,4292616679}
for _, asset in ipairs(Assets) do
game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end

local newAnim = Instance.new('Animation')
newAnim.AnimationId = "rbxassetid://" ..Assets[math.random(1,#Assets)]

Chair.Changed:Connect(function(property)
    if property == 'Occupant' then
        local occupant = Chair.Occupant
        if not occupant then if AnimationIsPlaying then AnimationIsPlaying:Stop() return end end
        AnimationIsPlaying = occupant:LoadAnimation(newAnim)
        AnimationIsPlaying:Play()
    end
end)
0
Works fine for me, remember math.random is 100% luck, its rare, but you could still get the same sitting animation 50 times in a row. moo1210 587 — 4y
0
oh. I thought something was blocking it from having the other animations not working. TheBuliderMC 84 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

"Works fine for me, remember math.random is 100% luck, its rare, but you could still get the same sitting animation 50 times in a row." -Moo1210

Ad

Answer this question