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

Moving tool to players backpack doesnt seem to work?

Asked by
TudiPYM 12
3 years ago
local player = game.Players.LocalPlayer

if player.Name == "TudiPYM" then
    local register = game.ReplicatedStorage:FindFirstChild("Black Registry")
    local clone = register:Clone()
    clone.Parent = player.Backpack
end

Doesn't seem to work. (I put the script in ServerScriptService)

2 answers

Log in to vote
0
Answered by
achdef 0
3 years ago

Hi. First off, put it in a script. And try the following:

local OwnerId = {game.CreatorId}

game.Players.PlayerAdded:Connect(function(checkPlr)
if table.find(OwnerId, checkPlr.UserId) then
local newRegister = game:GetService("ReplicatedStorage"):WaitForChild("Black Registry")
local clone = newRegister:Clone()
clone.Parent = checkPlr.Backpack
wait(2)
print(#OwnerId.." players will be given a tool if online.")
else
warn("Someone joined but is not a owner! :(")
 end
end)

If it's do not work, tell me in the comments.

0
didn't work, the game is a group project and maybe I can use the player.Name to give the tool TudiPYM 12 — 3y
0
Hello TudiPYM! If you use "player.Name" it is the same as the ID of a person. A players name can be changed (Not saying that you would but if you do this would happen) therefor if you use player.Name another person with that name would run that function. Instead find your personal ID and type that in. wolftamer894 50 — 3y
Ad
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago
local player = game.Players.LocalPlayer 

that will only work in local scripts.

Try this.

game.Players.PlayerAdded:Connect(function(player)
    if player.Name == "TudiPYM" then
        local register = game.ReplicatedStorage:FindFirstChild("Black Registry")
        local clone = register:Clone()
        clone.Parent = player.Backpack
    end
end)
0
You haven't said why that is the case. Dovydas1118 1495 — 3y

Answer this question