I want my game to not be bypassed and cheated with NoClip and Instant Heal that can be obtained by all players, only I should get it, but for some reason, even if I tried so that the removal only does to other people, they still would get it. I'm not good a Lua Code so don't expect me to make some common mistakes.
Here's the code:
function onTouch(obj) game.Players.PlayerAdded:Connect(function(player) h = player.UserId end) if obj.Parent:findFirstChild("Humanoid")~=nil then local p=game.Players:findFirstChild(obj.Parent.Name) if p~=nil then local ch = p.Backpack:getChildren() if h ~= 1403714853 then for i = 1, #ch do if ch[i].Name~="NoClip" and ch[i].Name~="Heal" and ch[i].Name~="Window" and ch[i].Name~="Mop" and ch[i].Name~="Bathroom" and ch[i].Name~="Water" and ch[i].Name~="Weed" then ch[i]:Remove() end end end end end script.Parent.Touched:connect(onTouch) end
I don't want players to instantly beat the game with cheats. So if anyone has an answer please do it.
so what you want is to create a table with userids as a whitelist, and if the player's userid is in the table, it will give the item to the player.
here's how you do it:
-- extra note: add a semicolon or comma after every item in a table, or else it error. whitelist = { -- the whitelist i was talking about 291424954; -- my user id lol, change if you want 1403714853 -- your user id } local Players = game:GetService("Players") script.Parent.Touched:Connect(function(obj) if obj.Parent:FindFirstChild("Humanoid") then local character = obj.Parent local player = Players:GetPlayerFromCharacter(obj.Parent) -- yes, getplayerfromcharacter is an actual function if table.find(whitelist,player.UserId) then -- item giver code here end end end)