Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Moving tool to players backpack doesnt seem to work?

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

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.

2 comments

0

didn't work, the game is a group project and maybe I can use the player.Name to give the tool

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.

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)

1 comment

0

You haven't said why that is the case.

This discussion is preserved as it was. New answers, comments, and votes are closed.