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

How to clone a tool?

I put a Tool(Cup (Empty)) in the StarterGui because im trying to clone it into your inventory after you touch a brick, ive only got,

brick = script.Parent
brick.Touched:connect(function(part)
	game.StarterGui.Cup (Empty):Clone().Parent = StarterPack
end)

But Its not working

1 answer

✓ Accepted answer

It's just because of the name. You can't list it like that if there's a space or symbol in the name. You have to either rename it, or do something like this

brick = script.Parent --the part that gives the item
brick.Touched:connect(function(part) --When the part is touched,
	if part.Parent.Humanoid then
		if part.Parent.Humanoid.Health > 0 then --if the part is part of a live character model
			Player = game.Players:GetPlayerFromCharacter(part.Parent) --gets the player
   			game.ReplicatedStorage["Cup (Empty"]:clone().Parent = Player.Backpack --clones the tool from replicated storage and puts it in the backpack.
		end
	end
end)

Also be aware that if you put it in the StarterPack, the player won't see the item until they restart their character.

2 comments

0

How can I put it into a characters inventory?

0

I've edited the script. Put the tool in ReplicatedStorage, not StarterGUI. StarterGUI is for GUIs. Replicated storage is for storing items and models. If the part that touched the brick is a hat though, the event will disconnect. Make the brick smaller than a character model.

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