So, I’m trying to make a LocalScript in StarterPlayerScript that is J button activates/deactivates them. Where do I put the animation too? It’s looks green film icon idk
My script:
local UIS = game:GetService("UserInputService")
local Playing = false
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode = Enum.KeyCode.J then
if Playing == false then
Playing = true
Run.RunAnim:Play()
elseif Playing == true then
Playing = false
Run.RunAnim:Stop()
end
end
end)
No, you do not put animations into local scripts, you only put them on rigged models. So, the script is fine, no need to change anything unless there are errors
If you’re trying to play an animation for a character, you need to load the animation onto the humanoid first:
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local Player = Players.LocalPlayer
local Playing = false
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationTrack = Humanoid:LoadAnimation(Run.RunAnim)
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode = Enum.KeyCode.J then
if Playing == false then
Playing = true
AnimationTrack:Play()
elseif Playing == true then
Playing = false
AnimationTrack:Stop()
end
end
end)