Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animation playing gui doesn't seem to function?

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.

1 answer

Try this instead.

local playingAnim = true
	Button.MouseButton1Down:connect(function()
if  playingAnim then
   playingAnim = false

local player = game.Players.LocalPlayer.Character
local animation = Instance.new("Animation", player)
animation.AnimationId = "489500953"
local animationTrack = player.Character.Humanoid:LoadAnimation(anim1)
animationTrack:Play()

wait(1)
playingAnim = true
end
end)

4 comments

0

This seems to cause nothing but the same, click on the button, nothing happens.

0

Please explain your answer even if doesn't work :/

0

Try not to use game.StarterGui - instead, put the script in StarterGui and script from there.

0

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.