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

GUI button that plays an animation?

I have a gui button to do an animation, in studio it works ,but in the game it doesnt work. Could anyone help me create a script that plays a animaion when the gui is pressed? All help much appreciated!

2 comments

0

The event used is called MouseButton1Down fyi

0

also make sure the script is compatible with FE

1 answer

✓ Accepted answer

Don't really feel like writing the whole script but since you have to play animations on the server then you'll need a RemoteEvent in the ReplicatedStorage or wherever. Then do something like this:

local script

local gui = script.Parent
local event = game.ReplicatedStorage.event

gui.MouseButton1Down:Connect(function()
	event:FireServer()
end)

script

local char = script.Parent
local event = game.ReplicatedStorage.event
local AnimationTrack --set to location of your animation track
local Animation = char.Humanoid:LoadAnimation(AnimationTrack)

event.OnServerEvent:Connect(function(player)
	if player.Name == char.Name then
		Animation:Play()
	end
end)

2 comments

0

Humanoid is not a valid member of workspace?

0

make sure the scripts is in StarterPlayer > StarterCharacterScripts

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