I have an animation game that after I play an animation it adds +1 value to my leaderstats. I used a remote event to fire to the server and add the value there but it does not work.

Local Script:

aughhButton.MouseButton1Click:Connect(function() -- AUGHH Animation
	
	-- Variables
	local humanoid = rig1:WaitForChild("Humanoid")
	
	-- Camera
	camera.CFrame = aughhCameraPart.CFrame
	camera.FieldOfView = 40
	
	-- Main
	frame.Visible = false
	humanoid:LoadAnimation(aughhAnimation):Play()
	aughhSound:Play()
	
	wait(7)
	
	frame.Visible = true
	aughhSound:Stop()
	humanoid:LoadAnimation(aughhAnimation):Stop()
	camera.FieldOfView = 70
        remoteEvent:FireServer()
	
end)

Script in Server Script Service:

remoteEvent.OnServerEvent:Connect(function(player)
        
        player.leaderstats.Plays.Value = player.leaderstats.Plays.Value + 1
        
end)

and if you can, help me make this more secure. thanks :)

4 comments

0
  1. I'd suggest you change "player.leaderstats.Plays.Value = player.leaderstats.Plays.Value + 1" to "player.leaderstats.Plays.Value+=1 to shorten code. Next, try printing when theres an event, or before firing, so you can see where the code stops
0

Any errors in output?

0

i managed to find out a fix (i think it was affected by other scripts in the server script thats why it wasnt working)

0

Hope that remote event is sanitized as heck. The title itself made me feel unsafe.