#Help with giving devs noclip tool

1 messages · Page 1 of 1 (latest)

hollow raven
#

I'm making a i'm making a tower game, so i added a noclip tool in serverStorage which will be given to players if they're a dev. Thing is, the tool isn't being given to the player.

This is the script currently (names hidden because yes):

local Players = game:GetService("Players")
local tool = game.ServerStorage.Noclip

local devs = {
["name"] = true,
["name"] = true,
["name"] = true,
["name"] = true,
["name"] = tru
}

local function isDeveloper(player)
  return devs[player.Name] == true
end

local function giveTool(player, tool)
  local backpack = player:FindFirstChildOfClass("Backpack")
  if backpack then
    tool.Parent = backpack
  end
end

Players.PlayerAdded:Connect(function(player)
  local playerJoined = player.name
    if isDeveloper(player) then
      game.ReplicatedStorage.BellSfxEvent:FireAllClients()
      giveTool(player,tool)
  end
end)

Any ideas as to why it's not working? This is a server script in ServerScriptService btw.

#

btw it doesn't give any errors and the function works

worthy mason
#

backpack gets cleared on character spawn, you're adding it too early. run givetool in player.characteradded should give better results

hollow raven
#

oh ok

#

i'll try one sec

#

am i doing it wrong? it still doesn't give me the noclip

Players.PlayerAdded:Connect(function(player)
    local playerJoined = player.Name
    if isDeveloper(player) then
        game.ReplicatedStorage.BellSfxEvent:FireAllClients()
        player.CharacterAdded:Connect(function(player)
            local character = playerJoined.Character
            if isDeveloper(player) then
                giveTool(player,tool)
            end
        end)
    end
end)
#

oh its function(character) isnt it

#

yeah

#

ty

west veldt
#

also its better to use userId so if any change on the name occurs it does not care

hollow raven
#

right

jade furnaceBOT
#

studio** You are now Level 1! **studio

hollow raven
#

i switched it to userId and now it doesn't work? (yes ofc i switched the names for the ids)

local tool = game.ServerStorage.Noclip

local devs = {
  ["id"] = true,
  ["id"] = true,
  ["id"] = true,
  ["id"] = true,
  ["id"] = true
}

local function isDeveloper(player)
  return devs[player.UserId] == true
end

local function giveTool(player, tool)
  local backpack = player:FindFirstChildOfClass("Backpack")
    if backpack then
    tool.Parent = backpack
  end
end


Players.PlayerAdded:Connect(function(player)
  local playerJoined = player.UserId
  if isDeveloper(player) then
    game.ReplicatedStorage.BellSfxEvent:FireAllClients()
    player.CharacterAdded:Connect(function(character)
      local character = playerJoined.Character
      if isDeveloper(player) then
        giveTool(player,tool)
      end
    end)
  end
end)```
hollow raven
#

fixed it :)