As part of the competitive part of my game, exploiters may have an interest in messing with my local script having to do with healing themselves. Are there any oversights where they can abuse this local script?
--local tool = script.Parent
--local p = game:GetService("Players")
--script.Parent.Equipped:connect(function()
-- burpfx:Play()
-- burpfx.TimePosition = 0
-- for i, v in ipairs(script.Parent:GetChildren()) do
-- if v:IsA("Part") then
-- v.CanCollide = false
-- end
-- end
--end)
--
--script.Parent.Unequipped:connect(function()
-- for i, v in ipairs(script.Parent:GetChildren()) do
-- if v:IsA("Part") then
-- v.CanCollide = true
-- end
-- end
--end)
--
--
script.Parent.Activated:connect(function()
if Eaten then
return
end
Eaten = true
wait(1)
drinkfx:Play()
if tool.Parent ~= game.Workspace and tool.Parent.Parent.Parent ~= game.Players then
drinkfx.Ended:Wait()
if tool.Parent == game.Players.LocalPlayer.Character then
game.ReplicatedStorage.Eat:FireServer() --server increases the player's health and hunger
tool:destroy()
else
Eaten = false
end
--game.ReplicatedStorage.DestroyTool:FireServer()
--print("remotes fired")
else
drinkfx.Ended:Wait()
Eaten = false
end
end)
I heard on the devforum exploiters can modify local script, however to conflicting degrees. Can they like change the conditions of the if statement, or delete the line where the tool is destroyed upon the one and only activation. meaning they could like spam heals or something, I’m hoping I don’t have to move everything except for the remote event to the server script and can leave it as is.
I don’t think it’s good practice to assure people that client code can’t be modified, it’s the client, there will be anti-cheat bypasses, and, at the end of the day, you cannot trust any information sent from the client because it is under the complete control of exploiters.
What you can do to reduce the impacts of exploiting is by doing “sanity checks”, for example, have the server track how long it’s been since the player fired the Eat event, and if it’s been less than the cooldown, return immediately to ignore the request.
My practice is this:
Treat local scripts as if they are unsecure, IE: A player can tamper with any of the values, and check the values that are sent to the server with a serversided variable check.
I only make sure to send a variable to the server to say “Hey a player wants to do x” and see if the player can do “x”. Strong emphasis on how i try to write, by eventing something to the server also allows the server to confirm what the user is able to do. so prevent exploiting by trying to confirm what the information is sent by the client to the server.