I have a LocalScript inside a tool which fires a RemoteEvent to give the player cash on the server. Should I play an animation on the LocalScript or a server script? If I do it on a LocalScript do I just put the animation code underneath the :FireServer() event?
LocalScript:
local Pan = script.Parent
local function PanActivated()
PanActivatedEvent:FireServer() -- The RemoteEvent name is PanActivatedEvent
end
Pan.Activated:Connect(PanActivated)
ServerScript:
local function PanActivatedServerEvent(Player)
-- Code for cash rewarding system
end
PanActivatedEvent.OnServerEvent:Connect(PanActivatedServerEvent)
Yes because if they can play it anyways why put it on the server? Anything the client can do should be put on client to save from extra server work which = lag
The question that should be asked is do you want the animation visible to all players when it plays, or just the one? Both methods have their benefits and limitations.
If it’s just the one player, then by all means, play it from the local script. The other players won’t see it, and the server won’t care about it. If all players who happen to be looking in that direction needs to see it, then it needs to be played from the server, which, as stated previously, playing the animation from the server increases the work the server has to do and can cause the server to lag out.
The only way that I can see an exploiter harming the server by playing an animation from the server would be trying to lag out the server and ruining the experience for other players.
Its that even if you played in on the server there is nothing stopping the client from doing something wlse. Like lets say you want to move the player 1000 units away. Doing it on the server isnt safer than doing it on the client because the client can move it self back 1000 units you get it? What im saying is there is no point on putting it on server, you put things on the server for securtiy but in this case its not any safer.