Animations not working right

So I am making a script where it changes the animation pose of a player. I am finding that it will be a bit weird at times. It shows the right animation locally but not globally, but then for some players, it will show it on you working but won’t show it working for you. If that makes sense.

I have tried all I know and I cannot quite figure out how to fix the issue. Here is the scripting, this is in a local script:

– Green Tree Casket Controls
— Created 3/2/2022
---- By: Sterling_ODeaghaidh
--------Variables--------------

UI = script.Parent
Casket = UI.Casket.Value
Curan = nil

------Begin Code-------------------

UI.Frame.High.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“High”)
end)

UI.Frame.Mid.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Mid”)
end)

UI.Frame.Hearse.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Hearse”)
end)

UI.Frame.Low.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Ground”)
end)

Casket.Folder.Prompt.OnClientEvent:Connect(function(M,I,I2)
local Plr = game.Players.LocalPlayer
local human = Plr.Character:FindFirstChild(“Humanoid”)
if M == “Attach” then
for i, c in pairs(Casket.Folder:GetChildren()) do
if c:IsA(“StringValue”) and c.Name == Plr.Name then
if I.Name == “Rear” then
local anim = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)
Curan = anim
if human ~= nil then
anim:Play()
anim:AdjustSpeed(0.5)
end
end
if I.Name == “Front” then
local anim1 = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
Curan = anim1
if human ~= nil then

					anim1:Play()
					anim1:AdjustSpeed(0.5)
				end
			end
			if I.Name == "Left" then
				local anim2 = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
				Curan = anim2
				if human ~= nil then
					anim2:Play()
					anim2:AdjustSpeed(0.5)
				end
			end
			if I.Name == "Right" then
				local anim3 = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
				Curan = anim3
				if human ~= nil then
					anim3:Play()
					anim3:AdjustSpeed(0.5)
				end
			end
			Casket.Folder.Prompt:FireServer("Attach",I,I2)
		end
	end
end
----
if M == "AnimReset" then
	for index, child1 in pairs(human:GetChildren()) do
		if child1:IsA("Animator") then
			child1:Destroy()
			wait(.1)
			local T = Instance.new("Animator")
			T.Name = "Animator"
			T.Parent = human
		end
	end
	Plr.PlayerScripts.PallLocal.Enabled = true
	UI:Destroy()
end
----
if M == "AnimChange" then
	for i, c in pairs(Casket.Folder:GetChildren()) do
		if c:IsA("StringValue") and c.Name == Plr.Name then
			if c.Value == "Rear" then
				local anim = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)
				Curan:Stop()
				Curan = anim
				if human ~= nil then
					anim:Play()
					anim:AdjustSpeed(0.5)
				end
			end
			if c.Value == "Front" then
				local anim1 = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
				Curan:Stop()
				Curan = anim1
				if human ~= nil then
					anim1:Play()
					anim1:AdjustSpeed(0.5)
				end
			end
			if c.Value == "Left" then
				local anim2 = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
				Curan:Stop()
				Curan = anim2
				if human ~= nil then
					anim2:Play()
					anim2:AdjustSpeed(0.5)
				end
			end
			if c.Value == "Right" then
				local anim3 = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
				Curan:Stop()
				Curan = anim3
				if human ~= nil then
					anim3:Play()
					anim3:AdjustSpeed(0.5)
				end
			end
		end
	end
end

end)

while true do wait()

if Casket.Folder.Lead1.Value == game.Players.LocalPlayer then
	UI.Frame.Visible = true
	script.Parent.LocalControlScript.Enabled = true
else
	UI.Frame.Visible = false
	script.Parent.LocalControlScript.Enabled = false
end

end

Found your problem. Your using a local script so that is why the animation is working only locally. Consider using a server script and doing an client to server event to trigger the animation.

1 Like

I keep seeing this going back and forth, what is better, local or global when it comes to animations? I mean ideally i need this to be local since its playing on a player as that’s what they say to do.

It doesn’t matter, Players will see animations with either type of script.

1 Like

Thanks thats what i am seeing, now the issue is its not really behaving how I want it. I am wanting to have it stop the previous animation and only show the one that i load. In practice this happens locally but to the server it blends the two similar to what happens when animation weights are applied. Which is what I don’t want. I only want one animation showing at a time. How do I fix that?

Try making an attribute in Workspace, Name it “RbxLegacyAnimationBlending”, set the type to “Bool”, then set it to True

How would that solve the issue because it did absolutely nothing?

From what i’ve seen it fixes animation blending

It doesnt for this situation. 3333333333333333333333333333333333333 ← adding this because they require a minimum number of characters

Use GetPlayingAnimationTracks(), Stop the ones you dont want then play the right one
image

The documentation says depracated, but its not, well doing it from Humanoid it is, cause it should be done from the Animator

So, this is where it gets weird.

I have it where it stops the track, and it shows stopped when doing the IsStopped (or however its spelled) value. Just when I go to test what it does, what ends up happening is locally it shows me the animations I wanna see, but to the server it shows a mix of the previous animation and the current one. Now does that mean that stopping an animation is a task for a server script or am I missing something?

You already decided if you are running the animations on ServerSide or ClientSide?

Actually, supposedly works like this.
If you load a track in client side with an animation, and then you play that track, the animation the chracter is playing should be automatically replicated to server.
If you do it from server, supposedly the client itself and other players can see the animation too.
So both ways are similar.

You sure you are handling this with only one side? or like a mix of both?

So here is how the system is currently set up.
1: A UI sends a ping to a serverside script that tells what action to do. The script loads the appropriate animation ID into the specified animation objects and then pings all clients (this is setup to work with multiple players) with parameters of what to do. The clientside script (same one that controls the UI) takes that message and loads then plays the animation called for.

I have it this way because of a “Version X of X” ordeal, been tweaking a lot so. I know this isn’t efficient but I’m just trying to get the stuff to work as its needed to before I go and optimize things for performance.

I know its a bit of spaghetti code

Ok, Client calls server to play an animation > server sets the IDs of Animation instances call client > client grabs the animation instance and load the animation to play the track?

One question, the Animation instances that the server is setting the ID, where are located?
When clients receive the call from server, what you are sending to client inside the parameters?

You tried just for testing?: Client calls server to play an animation > server grabs the animation instance, create the track and play it for that player

Only letting server handle the animation, when new client signal received to play a different animation, from server get all animation tracks, stop them and play the new animation.

After getting running that in a proper way, you could include the ClientSided playing animation

Let me just send the two scripts so you can see how its setup, i apologize in advance for any internal screaming the coding may cause. I am not a pro scripter

Server Side:
---- Green Tree F.S Pallbearer System
— Created: 3/2/2022
– Programer: Sterling_ODeaghaidh
----------Variables--------------------

Casket = script.Parent.Parent
Folder = script.Parent
L1 = script.Parent.Lead1
Bearers = {}
GRP = 1128069
–Animations
RightUp = “rbxassetid://12876232029”
RightDown = “rbxassetid://12876251917”
RightHearse = “rbxassetid://12876260284”
RightMid = “rbxassetid://12877813102”
LeftMid = “rbxassetid://12876275851”
LeftDown = “rbxassetid://12876281425”
LeftHearse = “rbxassetid://12876293046”
LeftUp = “rbxassetid://12876299461”
RearUp = “rbxassetid://10713550283”
RearDown = “rbxassetid://5717233729”
RearHearse = “rbxassetid://12876328969”
RearMid = “rbxassetid://5715697224”
RightShoulder = “rbxassetid://”
LeftShoulder = “rbxassetid://”
FrontMid = “rbxassetid://5715692732”
FrontDown = “rbxassetid://5717233729”


FuneralDirector = false
LIG = false
Curan = nil

--------Begin Code-----------
script.Parent.PallLocal.Parent = game.StarterPlayer.StarterPlayerScripts

script.Parent.Prompt.OnServerEvent:Connect(function(P,M,I,I2)

if M == "Animated" then
	Curan = I
end
----
if M == "Attach" then
	for i, c in pairs(Folder:GetChildren()) do 
		if c:IsA("StringValue") and c.Name == P.Name then
			if c.Value == "Front" or c.Value == "Rear" then
				P.Character.Humanoid.WalkSpeed = 10
				P.Character.Humanoid.JumpPower = 50
			else
				P.Character.Humanoid.WalkSpeed = 0
				P.Character.Humanoid.JumpPower = 0
			end
		end
	end
	if I2 == "Right" then
		I.HingeConstraint.Enabled = true
		I.HingeConstraint.Attachment1 = P.Character.RightHand.RightGripAttachment
	end
	if I2 == "Left" then
		I.HingeConstraint.Enabled = true
		I.HingeConstraint.Attachment1 = P.Character.LeftHand.LeftGripAttachment
	end
end
----
if M == "Initiate" then
	table.insert(Bearers,P.Character)
	if L1 == nil then
		LIG = false
		L1.Value = P
	elseif P:GetRankInGroup(GRP) >= 7 then
		LIG = true
		L1.Value = P
	end
end
----
if M == "High" then
	script.Front.AnimationId = FrontMid
	script.Rear.AnimationId = RearUp
	script.Left.AnimationId = LeftUp
	script.Right.AnimationId = RightUp
	Folder.Prompt:FireAllClients("AnimChange")
end
----
if M == "Mid" then
	script.Front.AnimationId = FrontMid
	script.Rear.AnimationId = RearMid
	script.Left.AnimationId = LeftMid
	script.Right.AnimationId = RightMid
	Folder.Prompt:FireAllClients("AnimChange")
end
----
if M == "Hearse" then
	script.Front.AnimationId = FrontMid
	script.Rear.AnimationId = RearHearse
	script.Left.AnimationId = LeftHearse
	script.Right.AnimationId = RightHearse
	Folder.Prompt:FireAllClients("AnimChange")	
end
----
if M == "Ground" then
	script.Front.AnimationId = FrontDown
	script.Rear.AnimationId = RearDown
	script.Left.AnimationId = LeftDown
	script.Right.AnimationId = RightDown
	Folder.Prompt:FireAllClients("AnimChange")
end
----
if M == "BearerRemove" then
	for i, c in ipairs(Bearers) do
		if c == P.Character then
			table.remove(Bearers,i)
		end
	end
	I.HingeConstraint.Attachment1 = nil
	for index, child in pairs(script.Parent:GetChildren()) do
		if child.Name == P.Name then
			child:Destroy()
		end
	end
	if P == L1.Value then
		local P1 = Bearers[1]
		if P1 then
			L1.Value = game.Players:GetPlayerFromCharacter(P1)
		else
			L1.Value = nil
			if Casket.Folder.HearseConnected.Value == false then
				Casket.Body:SetNetworkOwnershipAuto()
			end
		end
	end
	P.Character.Humanoid.WalkSpeed = 16
	P.Character.Humanoid.JumpPower = 50
	Casket.Folder.Prompt:FireClient(P,"AnimReset")
end
----
if M == "Move" then
	script.Parent.Parent.Attach.VectorForce.Force = I
end

end)

Client Side:
– Green Tree Casket Controls
— Created 3/2/2022
---- By: Sterling_ODeaghaidh
--------Variables--------------

UI = script.Parent
Casket = UI.Casket.Value
Plr = game.Players.LocalPlayer
human = Plr.Character:FindFirstChild(“Humanoid”)
Curan = nil
Right = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
Left = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
Front = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
Rear = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)

------Begin Code-------------------

UI.Frame.High.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“High”)
end)

UI.Frame.Mid.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Mid”)
end)

UI.Frame.Hearse.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Hearse”)
end)

UI.Frame.Low.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Ground”)
end)

Casket.Folder.Prompt.OnClientEvent:Connect(function(M,I,I2)
if M == “Attach” then
for i, c in pairs(Casket.Folder:GetChildren()) do
if c:IsA(“StringValue”) and c.Name == Plr.Name then
if I.Name == “Rear” then
if human ~= nil then
Rear:Play()
end
end
if I.Name == “Front” then
if human ~= nil then
Front:Play()
end
end
if I.Name == “Left” then
if human ~= nil then
Right:Play()
end
end
if I.Name == “Right” then
if human ~= nil then
Left:Play()
end
end
Casket.Folder.Prompt:FireServer(“Attach”,I,I2)
end
end
end
----
if M == “AnimChange” then
for i, c in pairs(Casket.Folder:GetChildren()) do
if c:IsA(“StringValue”) and c.Name == Plr.Name then
if c.Value == “Rear” then
Rear = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)
if human ~= nil then
Rear:Play(0,100,.3)
end
end
if c.Value == “Front” then
Front = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
if human ~= nil then
Front:Play(0,100,.3)
end
end
if c.Value == “Left” then
Right = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
if human ~= nil then
Right:Play(0,100,.3)
end
end
if c.Value == “Right” then
Left = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
if human ~= nil then
Left:Play(0,100,.3)
end
end
end
end
end
----
if M == “AnimReset” then
for index, child1 in pairs(human:GetChildren()) do
if child1:IsA(“Animator”) then
child1:Destroy()
wait(.1)
local T = Instance.new(“Animator”)
T.Name = “Animator”
T.Parent = human
end
end
Plr.PlayerScripts.PallLocal.Enabled = true
UI:Destroy()
end

end)

while true do wait()

if Casket.Folder.Lead1.Value == game.Players.LocalPlayer then
	UI.Frame.Visible = true
	script.Parent.LocalControlScript.Enabled = true
else
	UI.Frame.Visible = false
	script.Parent.LocalControlScript.Enabled = false
end

end

Remember to format the code use Ctrl+E
Server Side:

---- Green Tree F.S Pallbearer System
— Created: 3/2/2022
– Programer: Sterling_ODeaghaidh
----------Variables--------------------

Casket = script.Parent.Parent
Folder = script.Parent
L1 = script.Parent.Lead1
Bearers = {}
GRP = 1128069
–Animations
RightUp = “rbxassetid://12876232029”
RightDown = “rbxassetid://12876251917”
RightHearse = “rbxassetid://12876260284”
RightMid = “rbxassetid://12877813102”
LeftMid = “rbxassetid://12876275851”
LeftDown = “rbxassetid://12876281425”
LeftHearse = “rbxassetid://12876293046”
LeftUp = “rbxassetid://12876299461”
RearUp = “rbxassetid://10713550283”
RearDown = “rbxassetid://5717233729”
RearHearse = “rbxassetid://12876328969”
RearMid = “rbxassetid://5715697224”
RightShoulder = “rbxassetid://”
LeftShoulder = “rbxassetid://”
FrontMid = “rbxassetid://5715692732”
FrontDown = “rbxassetid://5717233729”

FuneralDirector = false
LIG = false
Curan = nil

--------Begin Code-----------
script.Parent.PallLocal.Parent = game.StarterPlayer.StarterPlayerScripts

script.Parent.Prompt.OnServerEvent:Connect(function(P,M,I,I2)

if M == "Animated" then
	Curan = I
end
----
if M == "Attach" then
	for i, c in pairs(Folder:GetChildren()) do 
		if c:IsA("StringValue") and c.Name == P.Name then
			if c.Value == "Front" or c.Value == "Rear" then
				P.Character.Humanoid.WalkSpeed = 10
				P.Character.Humanoid.JumpPower = 50
			else
				P.Character.Humanoid.WalkSpeed = 0
				P.Character.Humanoid.JumpPower = 0
			end
		end
	end
	if I2 == "Right" then
		I.HingeConstraint.Enabled = true
		I.HingeConstraint.Attachment1 = P.Character.RightHand.RightGripAttachment
	end
	if I2 == "Left" then
		I.HingeConstraint.Enabled = true
		I.HingeConstraint.Attachment1 = P.Character.LeftHand.LeftGripAttachment
	end
end
----
if M == "Initiate" then
	table.insert(Bearers,P.Character)
	if L1 == nil then
		LIG = false
		L1.Value = P
	elseif P:GetRankInGroup(GRP) >= 7 then
		LIG = true
		L1.Value = P
	end
end
----
if M == "High" then
	script.Front.AnimationId = FrontMid
	script.Rear.AnimationId = RearUp
	script.Left.AnimationId = LeftUp
	script.Right.AnimationId = RightUp
	Folder.Prompt:FireAllClients("AnimChange")
end
----
if M == "Mid" then
	script.Front.AnimationId = FrontMid
	script.Rear.AnimationId = RearMid
	script.Left.AnimationId = LeftMid
	script.Right.AnimationId = RightMid
	Folder.Prompt:FireAllClients("AnimChange")
end
----
if M == "Hearse" then
	script.Front.AnimationId = FrontMid
	script.Rear.AnimationId = RearHearse
	script.Left.AnimationId = LeftHearse
	script.Right.AnimationId = RightHearse
	Folder.Prompt:FireAllClients("AnimChange")	
end
----
if M == "Ground" then
	script.Front.AnimationId = FrontDown
	script.Rear.AnimationId = RearDown
	script.Left.AnimationId = LeftDown
	script.Right.AnimationId = RightDown
	Folder.Prompt:FireAllClients("AnimChange")
end
----
if M == "BearerRemove" then
	for i, c in ipairs(Bearers) do
		if c == P.Character then
			table.remove(Bearers,i)
		end
	end
	I.HingeConstraint.Attachment1 = nil
	for index, child in pairs(script.Parent:GetChildren()) do
		if child.Name == P.Name then
			child:Destroy()
		end
	end
	if P == L1.Value then
		local P1 = Bearers[1]
		if P1 then
			L1.Value = game.Players:GetPlayerFromCharacter(P1)
		else
			L1.Value = nil
			if Casket.Folder.HearseConnected.Value == false then
				Casket.Body:SetNetworkOwnershipAuto()
			end
		end
	end
	P.Character.Humanoid.WalkSpeed = 16
	P.Character.Humanoid.JumpPower = 50
	Casket.Folder.Prompt:FireClient(P,"AnimReset")
end
----
if M == "Move" then
	script.Parent.Parent.Attach.VectorForce.Force = I
end
end)

Client Side:

– Green Tree Casket Controls
— Created 3/2/2022
---- By: Sterling_ODeaghaidh
--------Variables--------------

UI = script.Parent
Casket = UI.Casket.Value
Plr = game.Players.LocalPlayer
human = Plr.Character:FindFirstChild(“Humanoid”)
Curan = nil
Right = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
Left = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
Front = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
Rear = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)

------Begin Code-------------------

UI.Frame.High.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“High”)
end)

UI.Frame.Mid.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Mid”)
end)

UI.Frame.Hearse.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Hearse”)
end)

UI.Frame.Low.MouseButton1Click:Connect(function()
Casket.Folder.Prompt:FireServer(“Ground”)
end)

Casket.Folder.Prompt.OnClientEvent:Connect(function(M,I,I2)
if M == “Attach” then
for i, c in pairs(Casket.Folder:GetChildren()) do
if c:IsA(“StringValue”) and c.Name == Plr.Name then
if I.Name == “Rear” then
if human ~= nil then
Rear:Play()
end
end
if I.Name == “Front” then
if human ~= nil then
Front:Play()
end
end
if I.Name == “Left” then
if human ~= nil then
Right:Play()
end
end
if I.Name == “Right” then
if human ~= nil then
Left:Play()
end
end
Casket.Folder.Prompt:FireServer(“Attach”,I,I2)
end
end
end
----
if M == “AnimChange” then
for i, c in pairs(Casket.Folder:GetChildren()) do
if c:IsA(“StringValue”) and c.Name == Plr.Name then
if c.Value == “Rear” then
Rear = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)
if human ~= nil then
Rear:Play(0,100,.3)
end
end
if c.Value == “Front” then
Front = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
if human ~= nil then
Front:Play(0,100,.3)
end
end
if c.Value == “Left” then
Right = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
if human ~= nil then
Right:Play(0,100,.3)
end
end
if c.Value == “Right” then
Left = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
if human ~= nil then
Left:Play(0,100,.3)
end
end
end
end
end
----
if M == “AnimReset” then
for index, child1 in pairs(human:GetChildren()) do
if child1:IsA(“Animator”) then
child1:Destroy()
wait(.1)
local T = Instance.new(“Animator”)
T.Name = “Animator”
T.Parent = human
end
end
Plr.PlayerScripts.PallLocal.Enabled = true
UI:Destroy()
end

end)

while true do wait()

if Casket.Folder.Lead1.Value == game.Players.LocalPlayer then
	UI.Frame.Visible = true
	script.Parent.LocalControlScript.Enabled = true
else
	UI.Frame.Visible = false
	script.Parent.LocalControlScript.Enabled = false
end
end

I honestly didnt know how to format code on the forum.

Here this should be right
Client Side:

-- Green Tree Casket Controls
--- Created 3/2/2022
---- By: Sterling_ODeaghaidh
--------Variables--------------

UI             = script.Parent
Casket         = UI.Casket.Value
Plr            = game.Players.LocalPlayer
human          = Plr.Character:FindFirstChild("Humanoid")
Curan          = nil
Right          = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
Left           = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
Front          = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
Rear           = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)

------Begin Code-------------------


UI.Frame.High.MouseButton1Click:Connect(function()
	Casket.Folder.Prompt:FireServer("High")
end)

UI.Frame.Mid.MouseButton1Click:Connect(function()
	Casket.Folder.Prompt:FireServer("Mid")
end)

UI.Frame.Hearse.MouseButton1Click:Connect(function()
	Casket.Folder.Prompt:FireServer("Hearse")
end)

UI.Frame.Low.MouseButton1Click:Connect(function()
	Casket.Folder.Prompt:FireServer("Ground")
end)

Casket.Folder.Prompt.OnClientEvent:Connect(function(M,I,I2)
	if M == "Attach" then
		for i, c in pairs(Casket.Folder:GetChildren()) do
			if c:IsA("StringValue") and c.Name == Plr.Name then
				if I.Name == "Rear" then
					if human ~= nil then
						Rear:Play()
					end
				end
				if I.Name == "Front" then
					if human ~= nil then
						Front:Play()
					end
				end
				if I.Name == "Left" then
					if human ~= nil then
						Right:Play()
					end
				end
				if I.Name == "Right" then
					if human ~= nil then
						Left:Play()
					end
				end
				Casket.Folder.Prompt:FireServer("Attach",I,I2)
			end
		end
	end
	----
	if M == "AnimChange" then
		for i, c in pairs(Casket.Folder:GetChildren()) do
			if c:IsA("StringValue") and c.Name == Plr.Name then
				if c.Value == "Rear" then
					Rear = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Rear)
					if human ~= nil then
						Rear:Play(0,100,.3)
					end
				end
				if c.Value == "Front" then
					Front = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Front)
					if human ~= nil then
						Front:Play(0,100,.3)
					end
				end
				if c.Value == "Left" then
					Right = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Right)
					if human ~= nil then
						Right:Play(0,100,.3)
					end
				end
				if c.Value == "Right" then
					Left = human.Animator:LoadAnimation(Casket.Folder.PallbearerScript.Left)
					if human ~= nil then
						Left:Play(0,100,.3)
					end
				end
			end
		end
	end
	----
	if M == "AnimReset" then
		for index, child1 in pairs(human:GetChildren()) do
			if child1:IsA("Animator") then
				child1:Destroy()
				wait(.1)
				local T = Instance.new("Animator")
				T.Name = "Animator"
				T.Parent = human
			end
		end
		Plr.PlayerScripts.PallLocal.Enabled = true
		UI:Destroy()
	end
	
end)


while true do wait()
	
	if Casket.Folder.Lead1.Value == game.Players.LocalPlayer then
		UI.Frame.Visible = true
		script.Parent.LocalControlScript.Enabled = true
	else
		UI.Frame.Visible = false
		script.Parent.LocalControlScript.Enabled = false
	end
	
end

Server Side:

---- Green Tree F.S Pallbearer System
--- Created: 3/2/2022
-- Programer: Sterling_ODeaghaidh
----------Variables--------------------

Casket                  = script.Parent.Parent
Folder                  = script.Parent
L1                      = script.Parent.Lead1
Bearers                 = {}
GRP                     = 1128069
--Animations
RightUp                 = "rbxassetid://12876232029"
RightDown               = "rbxassetid://12876251917"
RightHearse             = "rbxassetid://12876260284"
RightMid                = "rbxassetid://12877813102"
LeftMid                 = "rbxassetid://12876275851"
LeftDown                = "rbxassetid://12876281425"
LeftHearse              = "rbxassetid://12876293046"
LeftUp                  = "rbxassetid://12876299461"
RearUp                  = "rbxassetid://10713550283"
RearDown                = "rbxassetid://5717233729"
RearHearse              = "rbxassetid://12876328969"
RearMid                 = "rbxassetid://5715697224"
RightShoulder           = "rbxassetid://"
LeftShoulder            = "rbxassetid://"
FrontMid                = "rbxassetid://5715692732"
FrontDown               = "rbxassetid://5717233729"

-----------------       ---------------

FuneralDirector         = false
LIG                     = false
Curan                   = nil

--------Begin Code-----------
script.Parent.PallLocal.Parent = game.StarterPlayer.StarterPlayerScripts



script.Parent.Prompt.OnServerEvent:Connect(function(P,M,I,I2)
	
	if M == "Animated" then
		Curan = I
	end
	----
	if M == "Attach" then
		for i, c in pairs(Folder:GetChildren()) do 
			if c:IsA("StringValue") and c.Name == P.Name then
				if c.Value == "Front" or c.Value == "Rear" then
					P.Character.Humanoid.WalkSpeed = 10
					P.Character.Humanoid.JumpPower = 50
				else
					P.Character.Humanoid.WalkSpeed = 0
					P.Character.Humanoid.JumpPower = 0
				end
			end
		end
		if I2 == "Right" then
			I.HingeConstraint.Enabled = true
			I.HingeConstraint.Attachment1 = P.Character.RightHand.RightGripAttachment
		end
		if I2 == "Left" then
			I.HingeConstraint.Enabled = true
			I.HingeConstraint.Attachment1 = P.Character.LeftHand.LeftGripAttachment
		end
	end
	----
	if M == "Initiate" then
		table.insert(Bearers,P.Character)
		if L1 == nil then
			LIG = false
			L1.Value = P
		elseif P:GetRankInGroup(GRP) >= 7 then
			LIG = true
			L1.Value = P
		end
	end
	----
	if M == "High" then
		script.Front.AnimationId = FrontMid
		script.Rear.AnimationId = RearUp
		script.Left.AnimationId = LeftUp
		script.Right.AnimationId = RightUp
		Folder.Prompt:FireAllClients("AnimChange")
	end
	----
	if M == "Mid" then
		script.Front.AnimationId = FrontMid
		script.Rear.AnimationId = RearMid
		script.Left.AnimationId = LeftMid
		script.Right.AnimationId = RightMid
		Folder.Prompt:FireAllClients("AnimChange")
	end
	----
	if M == "Hearse" then
		script.Front.AnimationId = FrontMid
		script.Rear.AnimationId = RearHearse
		script.Left.AnimationId = LeftHearse
		script.Right.AnimationId = RightHearse
		Folder.Prompt:FireAllClients("AnimChange")	
	end
	----
	if M == "Ground" then
		script.Front.AnimationId = FrontDown
		script.Rear.AnimationId = RearDown
		script.Left.AnimationId = LeftDown
		script.Right.AnimationId = RightDown
		Folder.Prompt:FireAllClients("AnimChange")
	end
	----
	if M == "BearerRemove" then
		for i, c in ipairs(Bearers) do
			if c == P.Character then
				table.remove(Bearers,i)
			end
		end
		I.HingeConstraint.Attachment1 = nil
		for index, child in pairs(script.Parent:GetChildren()) do
			if child.Name == P.Name then
				child:Destroy()
			end
		end
		if P == L1.Value then
			local P1 = Bearers[1]
			if P1 then
				L1.Value = game.Players:GetPlayerFromCharacter(P1)
			else
				L1.Value = nil
				if Casket.Folder.HearseConnected.Value == false then
					Casket.Body:SetNetworkOwnershipAuto()
				end
			end
		end
		P.Character.Humanoid.WalkSpeed = 16
		P.Character.Humanoid.JumpPower = 50
		Casket.Folder.Prompt:FireClient(P,"AnimReset")
	end
	----
	if M == "Move" then
		script.Parent.Parent.Attach.VectorForce.Force = I
	end
	
end)