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

How do I fix OnSelected Animation tool?

Asked by
TofuBytes 500 Moderation Voter
10 years ago

The HopperBin I used worked in Solo mode, but I'm confused on why it won't work in Play mode. FilteringEnabled is not on and I am using a LocalScript. Changing it to a regular script does nothing. Any help to why?

local dancing = false
local human = game.Players.LocalPlayer.Character

danceanim = Instance.new('Animation', human)
danceanim.Name = 'dance'
danceanim.AnimationId = "http://www.roblox.com/asset?ID=169892383"

local cur_anim = nil
function onSelected()
if dancing == false then
dancing = true
cur_anim = human.Humanoid:LoadAnimation(danceanim)
cur_anim:Play()
print('Dancing')
end
end

function unSelected()
if dancing == true then
dancing = false
if cur_anim ~= nil then
cur_anim:Stop()
cur_anim = nil
end
print('Dancing Stopped')
end
end

script.Parent.Selected:connect(onSelected)
script.Parent.Deselected:connect(unSelected)

Answer this question