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

How do you change UserData with RemoteEvents?

Asked by 3 years ago
Edited 3 years ago

In order to make a stats system I've been told to use RemoteEvents, so that the game is less exploitable, but I just don't know what im doing wrong. My script:

game.Replicatedstorage.DamageIncreasedEvent.OnServerEvent:Connect(function(plr)
 plr.Stats.Damage = plr.Stats.Damage + 1
end)

But everytime I try it, I get an error... The script is inside ServerScriptService and plr.Stats.Damage is an IntValue. As always, thanks in advance!

0
Are you sure your local script is firing the event? What does the error say? TaxesArentAwesome 514 — 3y
0
What's the error? IdealistDeveloper 234 — 3y
0
The error says : "Attempt to perform arithmetic on local ‘Damage’ value (a userdata value) " User#34929 0 — 3y
0
You're doing plr. Stats.Damage instead of plr.Stats.Damage Spjureeedd 385 — 3y
View all comments (3 more)
0
I mean you have a space Spjureeedd 385 — 3y
0
? User#34929 0 — 3y
0
I just typed it on here. On the actual script it's correct. User#34929 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

You need to change the value, not the object itself.

plr.Stats.Damage.Value = plr.Stats.Damage.Value +1
0
Wait, lemme just try that. User#34929 0 — 3y
1
Thank you very much! It works! User#34929 0 — 3y
Ad

Answer this question