Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Jxyzxrr 13
5 years ago

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.

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. VVickedDev 54 — 5y
0
Dude, cursing is against the rules of this site. You better delete that comment fast or else you're gonna get suspended oof Mr_Unlucky 1085 — 5y

1 answer

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago

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!

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. Jxyzxrr 13 — 5y
0
doesn't work though, im trying to make the tool only available to admins Jxyzxrr 13 — 5y
Ad

Answer this question