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.
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
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!
--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()
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