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

I'm making a money remote event that gives a player money. It doesn't work, why?

Asked by 5 years ago

So, I have a RemoteEvent called AddMoney. I keep on getting this error: 10:01:43.603 - Value is not a valid member of Player. I don't know if I have something wrong with the ServerScript or the LocalScript, but I need to fix this. Any help?

ServerScript:

1game.ReplicatedStorage.Events.AddMoney.OnServerEvent:Connect(function(player, cash)
2    for _,v in pairs(game.ServerStorage.PlayerMoney:GetChildren()) do
3        if v.Name == player.Name then
4            v.Value = v.Value + cash.Value
5        end
6    end
7end)

LocalScript:

01local events = game:GetService("ReplicatedStorage").Events
02local addImage = events.AddImage
03local addMoney = events.AddMoney
04 
05local player = game.Players.LocalPlayer
06local gui = player.PlayerGui.ShipmentGui.ShipmentFrame
07 
08local debounce = false
09for _,v in pairs(gui.ShipmentButtons:GetChildren()) do
10    if (v:IsA("TextButton")) then
11        local value = v.ItemUnlocked
12        if (value) then
13            v.MouseButton1Click:Connect(function()
14                if (value.Value == true) then
15                    if (debounce == false) then
View all 29 lines...

If you're confused with the "PlayerMoney", that is just a value stored in the server so that it can't be hacked by any clients

0
The code has a security flaw: when firing the RemoteEvent, the client is able to set `cash` to an arbitrary value, which isn't probably what you want. You may want to consider validating the amount of money to add on the server, or creating separate events that yield fixed amounts (specified in server scripts) of cash. Also, keep in mind that the MouseButton1Click debounce doesn't affect the gskw 1046 — 5y
0
server, so you may want to implement rate-limiting on the server side as well to prevent the system from being exploited. gskw 1046 — 5y

1 answer

Log in to vote
2
Answered by
SmartNode 383 Moderation Voter
5 years ago

When your firing from the client, never put your player as an argument because ROBLOX automatically does this for you.

Ad

Answer this question