Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my admin only tool script not remove the tool for non-admins?

local admins = {"j"} game.Players.PlayerAdded:connect(function(plr) local allowed = false for i = 1, #admins do if plr.Name == admins[i] then allowed = true end end if allowed == false then plr.Backpack:WaitForChild("Kick"):Destroy() end end)

The script above is supposed to remove the "Kick" tool from a players backpack but it literally does nothing. No errors, no nothing. It's stored in ServerScriptService.

2 comments

0

"J' is not a user. What exactly are u trying to do? Why is admins a array table? Inserting the tool into backpack and then destroying will cause lag sometimes. Just make a different script that inserts the tool from somewhere into the admins. plr is not defined. Hope this helped and if it did pls upvote.

0

Dude, cursing is against the rules of this site. You better delete that comment fast or else you're gonna get suspended oof

1 answer

Here's the problem. You should be cloning the "Kick" tool into the Player's backpack and having said tool inside the ReplicatedStorage.

local admins = {ā€œjā€}  
game.Players.PlayerAdded:connect(function(plr)  
	local allowed = false  
	for i = 1, #admins do  
		if [plr.Name](http://plr.name/) == admins[i] then  
			allowed = true  
		end  
	end  
	if allowed then
		local newKickTool = game:GetService("ReplicatedStorage").Kick:Clone()
		newKickTool.Parent = plr.Backpack
	end
end)

Another thing i'm wondering is in line five. Why would you need to get a URL to check if someone is an admin? Why not use UserIds?

Anyways, in the code above we have a conditional statement that checks if the allowed boolean is true. If it is we'll get the Kick tool inside the ReplicatedStorage and clone it, and parent it into the backpack. Simple!

2 comments

0

I didn't put any url's in it, maybe it glitched because i put plr.Name down and it thought it was a website.

0

doesn't work though, im trying to make the tool only available to admins

This discussion is preserved as it was. New answers, comments, and votes are closed.