What should i change to make this play on the player

Im trying to change this script to make it play on the player, and the sever so other people can see it.
But i dont know exactly what to change to make it do so. I know it likely involves :FindFirstChild (“Humanoid”)

local Rig = workspace.TemplateR6
local Rstor = game:GetService("ReplicatedStorage")
local Orb = Rig.Humanoid:LoadAnimation(Rstor.Animations.OrbFire)
local Isactive = false
local UIS = game:GetService("UserInputService")

function PlayAnim(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if Isactive == false then
			Isactive = true
			Orb:Play()
			wait(0.917)
			Isactive = false
		end
	end
end
UIS.InputBegan:Connect(PlayAnim)

This script is currently on a localscript in starterplayerscripts
and i need to change it so part of the code is in a remote event in rep storage.

Humanoids have a child called an Animator that, when playing animations on a character, will replicate it to all other clients and the server. Try loading the animation like that instead.

local Rig = workspace.TemplateR6
local Rstor = game:GetService("ReplicatedStorage")
local Orb = Rig.Humanoid.Animator:LoadAnimation(Rstor.Animations.OrbFire)
local Isactive = false
local UIS = game:GetService("UserInputService")

function PlayAnim(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if Isactive == false then
			Isactive = true
			Orb:Play()
			wait(0.917)
			Isactive = false
		end
	end
end
UIS.InputBegan:Connect(PlayAnim)

What you have to do is, create a player variable first.

local player = game.Players.LocalPlayer

Then, change Orb to this:

local Orb = player.Character:WaitForChild(“Humanoid”).Animator:LoadAnimation(Rstor.Animations.OrbFire)

Keep all the other code the same.

Hope this helps!

1 Like