Not really the best person at scripting ever, but I've started to work on a GUI that's supposed to play an animation when you click on a textbutton in the GUI, but it just seems to do nothing with no reasoning for it. Here is the code:
Button = game.StarterGui.ScreenGui.AnimList.Sit2Anim
NotPlayingAnim = false
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=489500953"
local animTrack = nil
function playAnimation(Source)
Button.MouseButton1Down:connect(function()
if NotPlayingAnim then
local player = game.Players.LocalPlayer.Character
animTrack = player.Humanoid:LoadAnimation(animation)
animTrack:Play()
NotPlayingAnim = false
else
animTrack:Stop()
NotPlayingAnim = true
end
end)
end
I'm not really sure what else to try given I'm new to the whole scripting thing.

4 comments
This seems to cause nothing but the same, click on the button, nothing happens.
Please explain your answer even if doesn't work :/
Try not to use game.StarterGui - instead, put the script in StarterGui and script from there.
I did that, placed the script into StarterGui and picked out the button by using script.Parent.ScreenGui.Animlist.Sit2Anim. But again still nothing happens when I click on the button.