I'm making a money remote event that gives a player money. It doesn't work, why?
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:
1 | game.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 |
LocalScript:
01 | local events = game:GetService( "ReplicatedStorage" ).Events |
02 | local addImage = events.AddImage |
03 | local addMoney = events.AddMoney |
05 | local player = game.Players.LocalPlayer |
06 | local gui = player.PlayerGui.ShipmentGui.ShipmentFrame |
09 | for _,v in pairs (gui.ShipmentButtons:GetChildren()) do |
10 | if (v:IsA( "TextButton" )) then |
11 | local value = v.ItemUnlocked |
13 | v.MouseButton 1 Click:Connect( function () |
14 | if (value.Value = = true ) then |
15 | if (debounce = = false ) then |
17 | addMoney:FireServer(player, v.Money) |
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