Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you change UserData with RemoteEvents?

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!

7 comments

0

Are you sure your local script is firing the event? What does the error say?

0

What's the error?

0

The error says : "Attempt to perform arithmetic on local ‘Damage’ value (a userdata value) "

0

You're doing plr. Stats.Damage instead of plr.Stats.Damage

0

I mean you have a space

0

?

0

I just typed it on here. On the actual script it's correct.

1 answer

✓ Accepted answer

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

plr.Stats.Damage.Value = plr.Stats.Damage.Value +1

2 comments

0

Wait, lemme just try that.

1

Thank you very much! It works!

This discussion is preserved as it was. New answers, comments, and votes are closed.