Doesn't want to replicate the tool to the player

  1. I have the tool inside ReplicatedStorage and what I want is if the player clicks an object, it clones the tool and it goes into the backpack of the player.

  2. The issue is that it isn’t replicating and parenting to the player’s backpack.

Code

local box = script.Parent.Parent.Envelope1
local arrow = script.Parent.Parent.Arrow1

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	local gui = script.BoxUi:Clone()
	local gui2 = script.Inventory:Clone()
	gui2.Parent = plr.PlayerGui
	gui.Parent = plr.PlayerGui
	box.Transparency = 1
	box.CanCollide = false
	script.Parent.Parent.Checkpoint1.Transparency = 0.5
	script.Parent.Parent.Checkpoint1.PointLight.Enabled = true
	arrow.Part.Transparency = 0
	arrow.Part.PointLight.Enabled = true
	arrow.Wedge.Transparency = 0
	arrow.Wedge.PointLight.Enabled = true
	arrow.Wedge2.Transparency = 0
	arrow.Wedge2.PointLight.Enabled = true
	
	
	game:GetService("Players").PlayerAdded:Connect(function(Player)
		local Backpack = Player:WaitForChild("Backpack")
		local clonetool = game:GetService("ReplicatedStorage"):WaitForChild("Envelope")
		if clonetool and Backpack then
			clonetool:Clone().Parent = Backpack
		end
	end)
end)

Anybody have a fix?

Notes

This is a normal script placed inside of the model envelope (not tool)

Wait… the script isnt “saying” that you need to click the button same time anyone joins to work?

It isn’t a button but rather a model that when clicked, the model disappears and the “tool” is placed inside the players backpack

Why is there a PlayerAdded event in the MouseClick event? That just will add the tool on respawn, change your PlayerAdded event to

local Backpack = plr:WaitForChild("Backpack")
local clonetool = game:GetService("ReplicatedStorage"):WaitForChild("Envelope")
clonetool:Clone().Parent = Backpack

Also you don’t need to use WaitForChild variables if timeOut isn’t specified in an if statement since if the code continues, then we know those variables found something

So try to dont use

And try the same without this, but use the “plr” instead of the “Player” because you already say the player who clicked.