Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Add Leaderstats Value Through a Remote Event?

Asked by 2 years ago

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 :)

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 CocoDysphoria 67 — 2y
0
Any errors in output? SashaPro336 47 — 2y
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) djcraft1237 4 — 2y
0
Hope that remote event is sanitized as heck. The title itself made me feel unsafe. chessebuilderman 18 — 2y

Answer this question