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

Is it possible to give only one player a startergear?

Asked by
LawlR 182
6 years ago

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?

2 answers

Log in to vote
1
Answered by 6 years ago
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)
0
You shouldn't use StarterGear, really. Clone the tool and parent it to their Backpack anytime they spawn, rather. Link150 1355 — 6y
0
I'm going to upvote anyway, though. Link150 1355 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)

0
use code blocks PolyyDev 214 — 6y
0
that is also a very stupid, overcomplicated way of doing it... Something I would do. PolyyDev 214 — 6y

Answer this question