Animations problem

Alright, so basically, I have cuffs script, blah blah blah… When I cuff a player, I do see the cuff animation on my client, but the player doesn’t see the animation on his client. Also on the server-side screen, it looks broken too.

Player1 view (the one that is cuffing)

Player2 view (the one being cuffed)

image

Server view

image

The same happens, when the player isn’t cuffed, but he was cuffed before.

Player1 view (the one that cuffed)

Player2 view (the one that was cuffed)

image

Server view

It seems like the animations arent synced or something sort of that, but I could not find the solution for this.
Thanking you all in advance!

1 Like

What I would do is make a PlayServerAnimation RemoteEvent with the needed parameters and play the animation on the server, for anyone to see. I know animations are replicated but in this case, I don’t know your game structure, so not sure. In this case (or global ones), the parameters would be:

(Animator,Animation) -- Animator should be found at Humanoid.Animator, Animation should be an Animation or AnimationTrack, your choice
3 Likes

I’m sorry for a late answer, been busy… I will try your method out, thank you.

I may not understand how to do it, could you write a code for me?

Here’s my CuffModule code:

	RemoteEvent2:FireClient(targetPlayer, "AnimationStart", targetHum) -- Firing the Client to play animation
	
	local Animation = game.ReplicatedStorage.CuffAnimation:Clone()
	local Animator = targetHum:FindFirstChild("Animator")
	
	local AnimationTrack = Animator:LoadAnimation(Animation)
	AnimationTrack:Play()

Here’s the LocalScript code:

        local Animation = game.ReplicatedStorage.CuffAnimation:Clone()
		AnimationTrack = targetHum:LoadAnimation(Animation)
		AnimationTrack:Play()

The main problem is, only the one that is cuffing can see the animations work properly. The one that is getting cuffed, on his screen gets bugged animations, for example he gets cuffed animation when he isn’t cuffed, etc..

Honestly, in situations like this I HIGHLY advise running animations on the server. I encountered the same problem when scripting a fresh detain tool. Just fire the player over to the server and the player you clicked on, and play animations for both of their humanoids on the server. Hope this helps!

1 Like

How would I script that? I can not understand

So this would be your local script:

--LOCAL SCRIPT

local players = game:GetService("Players")
local lplayer = game:GetService("Players").LocalPlayer
local re = --WHERE EVER YOUR REMOTE EVENT IS

re:FireServer(lplayer, [THE OTHER PLAYER YOU INTERACTED WITH])
--SERVER SCRIPT

local re = --WHERE EVER YOUR REMOTE EVENT IS

re.OnServerEvent:Connect(Function(player, interactedplayer)

local namedplayer1 = player.Name
local namedplayer2 = interactedplayer.Name -- these two variables will let you then find the player you interacted with in the workspace by searching for their name

--do stuff here

end)

After all this, you can then load the animations to the humanoid by using namedplayer1 & 2

Like this:

local whateveryouranimationis = workspace.namedplayer2.Humanoid.Animator:LoadAnimation(ANIMATION_HERE)

whateveryouranimationis:Play()

Hope this helped!

1 Like

Alright, so I tried this, but then, how do I stop animations when the player is not cuffed anymore?
My script, that I tried, but it didn’t work:

	elseif state == "Stop" then
		for i, anim in pairs(workspace.namedPlayer2.Humanoid:GetPlayingAnimationTracks()) do
			anim:Stop()
		end
	end

You’ll have to use Animator | Roblox Creator Documentation

1 Like

Still doesn’t work… Maybe the problem is in something else?

My bad, I just forgot to activate the script…
But now, here’s the thing:
It just doesn’t work anymore…

So let’s see how it all works here:
My module script, CuffsModule:

RemoteEvent2:FireClient(targetPlayer, "AnimationStart", targetPlayer) 	

it does this, to fire the client about the player getting cuffed, then

Local script recieves it, and here’s the code:

RemoteEvent.OnClientEvent:Connect(function(state,targetPlayer)
	print(state.." "..targetPlayer.." proceeding animation..")
	
	if state == "AnimationStart" then
		print("Fired  an event to Play")
		RemoteEvent:FireServer(targetPlayer, Player, "Play")
	elseif state == "AnimationStop" then
		print("Fired an event to Stop")
		RemoteEvent:FireServer(targetPlayer, Player, "Stop")
	end
end)

First of all, it just doesn’t print anything (the localscript), probably the problem is in the localscript itself, and i dont get any errors in the output