The only way I can think of doing this is to check if that person is allowed it every time he/she respawns, then clone it from somewhere into their backpack. Is there any easier way to do this?
game:GetService("Players").PlayerAdded:Connect(function(player) if player.UserId == 0 then local tool = game:GetService("ServerStorage").Tool:Clone() --if this is a tool you have tool.Parent = player.StarterGear end end)
Very simple.
Here we gather data:
function checkPlayers()
local players = {}
for i,v in pairs(game.Players:GetPlayers()) do
players[i] = v.Name
players[i][i] = v.UserId
end
return players
end
First check for the tool.
tool = game.ServerStorage.myTool or game.ServerStorage["my Tool"]
Then we are going to check for the Player, but more precisely because we only want one specific player
PLAYERS = checkPlayers()
allowedPlayer = "theirName" or 0
-- user ID number
or
allowedPlayers = {"Player1","Player2","Player3"}
-- a tuple amount basically
Now check for their Backpack
function isPlayerAllowed(playerData)
if unpack(PLAYERS) == playerData then
BP = game Players.LocalPlayer.Backpack
end
return BP
end
BackPack = isPlayerAllowed(allowedPlayer)
cTool = tool:Clone()
game Players.PlayerAdded:Connect(function(player)
if not player then repeat wait() until game.Players.LocalPlayer end
player.CharacterAdded:Connect(function(character)
if not character then repeat wait() until player.Character end
if tool:IsDecendantOf(character) then
tool:Destroy()
cTool.Parent = BackPack
elseif cTool:IsDecendantOf(character) then
return
end
character.Humanoid.Died:Connect(function()
if player.CharacterAdded:Wait() then
cTool.Parent = BackPack
else
player:LoadCharacter()
cTool.Parent = BackPack
end
end)
end)
end)