Remember: The exploiter will always have the upper hand, so make sure to do as much as you can to stop them.
So coming from what you heard, you are going to have to send the server the value from the client anyway, as the server can't open it up. What I'd do is send the server the value, but to use some sort of sanity check.
(I'll explain later)
Local:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Event:FireServer(script.Parent.Money.Value, script.Parent.Price.Value)
Server:
local checked = false
game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player, money, price)
checked = true
game.ReplicatedStorage.Checking:FireClient(player, money, price)
wait(2)
checked = false
end)
Other Local (Should be in the same local script as the other.
game.ReplicatedStorage.Checking.OnClientEvent:Connect(function(player, money, price)
if money == script.Parent.Money.Value and price == script.Parent.Price.Value then
game.ReplicatedStorage.Checking:FireServer(player, money, price)
end
end)
Other Server (Should be same script as the other server script part)
game.ReplicatedStorage.Checking.OnServerEvent:Connect(function(player, money, price)
if checked == true then
if money >= price then
print("Bought")
else
print("Not Bought")
end
end
checked = false
end)
So what did we do? To some, this is called a sanity check. These are used to try to make an exploiter's achievement harder. Note that exploiters will always have the upper hand, but can be dealt with. (They can read and alter client code, but with the right set-up, we can get back at 'em.)
In our first part of the local script, we just sent the values. However, they'll be check later on.
In the first part of the server script, it actually sends the information right back to the client with a different RemoteEvent, and this is where we're able to compare information. We also set up a variable that's set to true when the RemoteEvent is passed to the server (Remember, exploiters can't edit server code!)
On the last part of the local script, it compares the numbers the server has and the numbers you currently have. If they match, huzzah, they'll go up to the server again. If it doesn't, it'll reject it and stop the pro if money >= price then
print("Bought")
else
print("Not Bought")
end process. And then on the last part of the server, it'll see if that checked value is right, making sure a hacker didn't send an event up from the client directly. After that, it'll then mark your purchase. Hopefully this isn't too confusing, and if you have any questions, I'll be glad to help.
6 comments
line 2 your using a variable money which is nil or misspelled
i just quickly remade that on this website nothing is misspelled or missing
it works when i add in the .Value in the local script
i dont want that because people will just exploit that easily
But there's no way to work unless you put .Value in the localscript.
can i use a remote function?