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

GUI button that plays an animation?

Asked by 5 years ago

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!

0
The event used is called MouseButton1Down fyi DeceptiveCaster 3761 — 5y
0
also make sure the script is compatible with FE DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
Humanoid is not a valid member of workspace? ultithe 4 — 5y
0
make sure the scripts is in StarterPlayer > StarterCharacterScripts Isaac020717 32 — 5y
Ad

Answer this question