Hello everyone let’s say i have a local script that lets you buy items and i used remote function to check in the server if the player has enough money and then send to the local script if it he can or cannot buy it by the player like so
Client :
local part = game.Workspace.Part
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local buyFunction = ReplicatedStorage.BuyFunction
local debounce = false
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
local canBuy = buyFunction:InvokeServer()
if canBuy then
print("Bought !")
else
print("Cannot buy it !")
end
task.wait(1)
debounce = false
end
end)
Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local buyFunction = ReplicatedStorage.BuyFunction
local itemPrice = 1000
buyFunction.OnServerInvoke = function(player)
if player:GetAttribute("Money") >= itemPrice then
return true
else
return false
end
end
Can a hacker just go into the local script and edit the canbuy variable to true or false like so
local part = game.Workspace.Part
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local buyFunction = ReplicatedStorage.BuyFunction
local debounce = false
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
local canBuy = buyFunction:InvokeServer()
canBuy = true
if canBuy then
print("Bought !")
else
print("Cannot buy it !")
end
task.wait(1)
debounce = false
end
end)