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

How to prevent tools from cloning itself?

I'm trying to make a hotel game. Ran into this glitch where the 'Staff Card' clones itself for some reason. I've looked everywhere in the game and I've yet to find the cause for it. Here's the script that gives the player the card. I would really appreciate it if someone found out. Thanks again!

game.Workspace.ChildAdded:connect(function(child)
	if game.Players:GetPlayerFromCharacter(child) then
		local player = game.Players:GetPlayerFromCharacter(child)
		if player:GetRankInGroup(script.GroupID.Value) >= script.RankID.Value then
			local ckey = game.ServerStorage["Staff Card"]:Clone()
		    ckey.Parent = player.Backpack
		end
	end
end)
print("The Staff Card has been added to your inventory.")

1 comment

0

The print is in the wrong place btw. It should be with the clone script, not outside of it

1 answer

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		if player:GetRankInGroup(script.GroupID.Value) >= script.RankID.Value then
			local ckey = game.ServerStorage["Staff Card"]:Clone()
			ckey.Parent = player.Backpack
		end
	end)
end)
print("The Staff Card has been added to your inventory.")

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