So i tried to whitelist the tool for a certain player so, when someone equips it and he's not whitelisted then it will destroy the tool, but if they are whitelisted then it will not be destroyed.
My current progress so far:
game.Players.PlayerAdded:connect(function(plr) if plr.name == "Thatisnotmyrealuser" then wait() else script.parent:destroy() end end)
You can just clone it to their StarterGear if they are whitelisted.
-- dictionary with names lowercased local WhiteList = {['azarth'] = true, ['you'] = true} -- location of tool local Tool = script:WaitForChild("Tool") local function PlayerJoined(Player) -- if whitelisted if WhiteList[Player.Name:lower()] then -- clone tool to StarterGear Tool:Clone().Parent = Player:WaitForChild('StarterGear') end end -- On join game.Players.PlayerAdded:Connect(PlayerJoined) -- Players not caught by event for i,v in pairs ( game.Players:GetPlayers()) do PlayerJoined(v) end
i have a pretty simple script but it works. what this script does is, when a player picks up a tool they by default equip the tool. so when the player equips the tool it checks if the players name is in a whitelist table or not if it is then it prints "whitelisted" elseif they are not in the whitelist table it destroys itself.
local whitelist = {"YourUser", "FriendsUser"} --add the whitelist users here script.Parent.Equipped:Connect(function() local char = script.Parent if char.Name == whitelist then print("whitelisted") elseif char.Name ~= whitelist then script.Parent:Destroy() end end)
just place this in a serverscript inside of your tool. hope this helped you :)
First, we need to see if the player is not “Theisnotmyrealuser”
game.Players.PlayerAdded:connect(function(plr) if not plr.name == "Thatisnotmyrealuser" then end end)
Now, we need to detect if the player has the tool
game.Players.PlayerAdded:connect(function(plr) if not plr.name == "Thatisnotmyrealuser" then local children = plr.Backpack:GetChildren() for i = 1, #children do local child = children[i] if child.Name == Tool then end end end)
Now, we need to remove it.
game.Players.PlayerAdded:connect(function(plr) if not plr.name == "Thatisnotmyrealuser" then local children = plr.Backpack:GetChildren() for i = 1, #children do local child = children[i] if child.Name == Tool then plr.Backpack:FindFirstChild("Tool"):Destroy() end end end)