so what do i do now, what do i modify?
im sorry, i replied that before reading the thread, it seems theres others who already assisted u in here, i just wanna ask, why is there player[CarName][CarName]?, u made both the parent and the children same name?,
but the problem seems to be because u didnt put the âplayerâ variable in server script remote function before the other variables, it should be
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, price, CarName)
if player.leaderstats.Money.Value < price then return end -- just added
player.leaderstats.Money.Value = player.leaderstats.Money.Value - price
player[CarName][CarName].Value = 2
end)
when getting OnServerEvent, the first variable are always the player firing the event, the order cant be change
You should check if the player has enough money on the server else they could have negative money.
ur right, i should have added that in their example script, i will
I doesnt remove the money i paid, im not getting any errors
Price should be defined on the server. You should not pass the price through the remote event.
so what do i do? whats the script now?
I think he means that you shouldâve just made a price variable on the script manually instead of using the remoteevent
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, price, CarName)
if player.leaderstats.Money.Value < price then return end -- just added
player.leaderstats.Money.Value -= price -- -= is same as Money.Value = Money.Value - price, also like they said, its more safe to check price from server rather than trusting the player firing of what the price is
player[CarName][CarName].Value = 2
end)
Woops, lol I made it without testing