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

how to make it so that if i click a button it runs the animation?

Asked by 3 years ago
Edited 3 years ago

i tried doing in starter player local script code:

local UserInputService = game:GetService("UserInputService")

local part = game.Workspace.Part

local JumpAnimation = script.JumpAnimation

local player = game.Players.LocalPlayer local char = player.Character

local hum = char.Humanoid

local JumpAnimationTrack = hum:LoadAnimation(JumpAnimation) local animation = game.StarterPlayer.StarterPlayerScripts.Animation

UserInputService.InputBegan:Connect(function(input,gameProcessedEvent) if input.KeyCode == Enum.KeyCode.G then JumpAnimationTrack:Play()

end
end)

also local script for animation

local JumpAnimation = script.JumpAnimation

local player = game.Players.LocalPlayer local char = player.Character local hum = char.Humanoid

local JumpAnimationTrack = hum:LoadAnimation(JumpAnimation)

JumpAnimationTrack:Play()

any way to get it working?

0
Is the animation made by yourself? Shounak123 461 — 3y
0
Also- Do you want a Model to do that or a Player? Finty_james 269 — 3y
0
Wait... Finty_james 269 — 3y
0
it still doesnt work crushersxd 15 — 3y
0
i want my player to fo that and yes its made by me crushersxd 15 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago

idk i dont use animations e.e think this is how

local UserInputService = game:GetService("UserInputService")

local part = game.Workspace.Part

local JumpAnimation = script.JumpAnimation

local player = game.Players.LocalPlayer local char = player.Character

local hum = char.Humanoid

UserInputService.InputBegan:Connect(function(input,gameProcessedEvent) 
    if gameProcessedEvent then
        return
    end

    if input.KeyCode == Enum.KeyCode.G then 
        JumpAnimation:Play()
    end
end)



Ad
Log in to vote
0
Answered by 3 years ago

Instead of using

char.Humanoid

You have to use

char:WaitForChild("Humanoid")

WaitForChild is important for getting characters Properties.

Log in to vote
0
Answered by
xxaxxaz 42
3 years ago

add a screen gui into starter gui. then rename it Emotes! put in a frame into the emotes. name it what you want. put in a text button into the frame. add a local script. the local script says local script:

local emote = name -- replace emote with the name of the emote
local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid",10)
local CanEmote = true
local CoolDown = 1

btn.MouseButton1Click:Connect(function()
    if CanEmote == true then
        CanEmote = false
        local dance = hum:LoadAnimation(script:FindFirstChild(emote))
        dance:Play()

        wait(CoolDown + dance.Length)
        CanEmote = true
    end
end)

after that place down a animation into the local script. put in the emote id through the property's tab! do not forget to rename the animation to the emote you puted into the script at local emote = name!

0
if this helped you please mark mine thx! xxaxxaz 42 — 3y

Answer this question