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

Can anyone help me with animation scripts?

Asked by 10 years ago

I made an animation GUI for my night club game,when i test the buttons,it won't play a dance animation,can anyone help me?here's the script

wait(1)
local frame=script.Parent
local user=game.Players.LocalPlayer
repeat wait() until user.Character local char=user.Character
local humanoid=char:WaitForChild("Humanoid")
local anim
function playanim(id)
    if char~=nil and humanoid~=nil then
        local id="rbxassetid://"..tostring(id)
        local oldanim=char:FindFirstChild("LocalAnimation")
        if anim~=nil then
            anim:Stop()
        end
        if oldanim~=nil then
            if oldanim.AnimationId==id then
                oldanim:Destroy()
                return
            end
            oldanim:Destroy()
        end
        local animation=Instance.new("Animation",char)
        animation.Name="LocalAnimation"
        animation.AnimationId=id
        anim=humanoid:LoadAnimation(animation)
        anim:Play()
    end
end
local b1=frame.Button1
b1.MouseButton1Down:connect(function() playanim(b1.AnimID.Value) end)
local b2=frame.Button2
b2.MouseButton1Down:connect(function() playanim(b2.AnimID.Value) end)
local b3=frame.Button3
b3.MouseButton1Down:connect(function() playanim(b3.AnimID.Value) end)
local b4=frame.Button4
b4.MouseButton1Down:connect(function() playanim(b4.AnimID.Value) end)
local b5=frame.Button5
b5.MouseButton1Down:connect(function() playanim(b5.AnimID.Value) end)
local b6=frame.Button6
b6.MouseButton1Down:connect(function() playanim(b6.AnimID.Value) end)
local b7=frame.Button7
b7.MouseButton1Down:connect(function() playanim(b7.AnimID.Value) end)
local b8=frame.Button8
b8.MouseButton1Down:connect(function() playanim(b8.AnimID.Value) end)
local b9=frame.Button9
b9.MouseButton1Down:connect(function() playanim(b9.AnimID.Value) end)
local b10=frame.Button10
b10.MouseButton1Down:connect(function() playanim(b10.AnimID.Value) end)
local b11=frame.Button11
b11.MouseButton1Down:connect(function() playanim(b11.AnimID.Value) end)
local b12=frame.Button12
b12.MouseButton1Down:connect(function() playanim(b12.AnimID.Value) end)
local b13=frame.Button13
b13.MouseButton1Down:connect(function() playanim(b13.AnimID.Value) end)
local b14=frame.Button14
b14.MouseButton1Down:connect(function() playanim(b14.AnimID.Value) end)
local b15=frame.Button15
b15.MouseButton1Down:connect(function() playanim(b15.AnimID.Value) end)
local b16=frame.Button16
b16.MouseButton1Down:connect(function() playanim(b16.AnimID.Value) end)
0
You can use loops for event connections, too! BlueTaslem 18071 — 10y

Answer this question