Issue with script which gives tool

Hello,

So I am trying to make it so when a player joins the game they get a tool. I understand you could just put it in startertool but later on I will make it so only a curtain rank in a group gets it.

Here is my script so far:

local LRBuild = game.ServerStorage.LRF3X:Clone()

game.Players.PlayerAdded:Connect(function(plr)

local playerback = plr.Backpack

LRBuild.Parent = playerback

end)
local GroupId = 0 -- Choose
local GroupRank = 255 -- Choose

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Char)
  local LRBuild = game.ServerStorage.LRF3X:Clone()
  
  local playerback = plr.Backpack
   
      if Player:GetRankInGroup(GroupId) == GroupRank then.
       LRBuild.Parent = playerback
     end
   end)
end)

You should put the LRBuild variable when the player joins, so it clones every time and doesn’t configure the same clone.

Good point. I did that but it still will not work.

@LifeDigger
Edited.

local GroupId = 0 -- Choose
local GroupRankId = 255 -- Choose
local ToolLocation = game:GetService("ServerStorage")

game.Players.PlayerAdded:Connect(function(plr)
  plr.CharacterAdded:Connect(function()
    local LRBuild = ToolLocation.LRF3X:Clone()
  
    local playerback = plr.Backpack
   
        if Player:GetRankInGroup(GroupId) == GroupRankId then.
           LRBuild.Parent = playerback
       end
   end)
end)

Use: if Player:GetRankInGroup(id) == rankid

Use CharacterAdded since backpack resets on spawn

1 Like

Unless if you’re wanting to put the Tool inside the Player’s backpack once, try this:

local LRBuild = game.ServerStorage.LRF3X

game.Players.PlayerAdded:Connect(function(Player)
    print("Player added")
    Player.CharacterAdded:Connect(function(Character)
        print("Character added")
        local ToolClone = LRBuild:Clone()
        ToolClone.Parent = Player.Backpack
        print("Tool added to backpack")
    end)
end)