Infinite Yield on ServerStorage:WaitForChild("Paper1") even though it exists

Well you don’t need this while loop because you put the tool in backpack from server.

So to fire an event when player leaves server i writed you this

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
	player.CharacterRemoving:Connect(function(char)
		-- THIS WILL BE FIRED WHEN PLAYER WILL LEAVE
	end)
	
end)

After some time of debugging. This is what i came up:

game.Players.PlayerAdded:Connect(function(plr)
          game.ReplicatedStorage.RemoteEvent1:FireClient(plr)
end)

Local script:

local plr = game.Players.LocalPlayer
game.ReplicatedStorage.RemoteEvent1.OnClientEvent:Connect(function()
	while true do
		print("a")
		local PaperTool = game.ReplicatedFirst:FindFirstChild("Paper"..(plr.SecretFolder.Paper.Value+1)):Clone()
		PaperTool.Parent = plr.Backpack
		print("ab")
		if plr.Backpack:FindFirstChild("Paper"..tostring(plr.SecretFolder.Paper.Value+1)) then
			print("break loop")
			break
		end
	end
end)

For some reason it prints “break loop” despite still not having the tool stored in my inventory

Because you are giving tool from local player and not from server, try to put the tool in player backpack from Server

1 Like