ok so somtimes doing game.player.localplayer.Character does not work sometimes even on a server script like for example here’s this script writing and it dosent work:
script.parent.Mouse1Click:Connect(Function(player)
local animation = ReplicatedStorage.EmoteAnimation
local loadedAnimation = workspace[player.Name].Humanoid:LoadAnimation(animation)
end)
You can’t reference a LocalPlayer from a server-sided script, that is only do-able from a LocalScript. If you want to reference all of the players, you can use a for loop:
local players = game.Players:GetChildren()
for _,player in pairs(players) do
local character = player.Character
-- insert code here
end
it’s beneficiary to use this solution. Sometimes, when the player is added, the player will load before their character loads, so when you call for their character, it wont BE THERE. this overall is the best way to do it.