Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to clone a tool?

Asked by
dreamy67 135
10 years ago

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

Log in to vote
1
Answered by 10 years ago

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.

0
How can I put it into a characters inventory? dreamy67 135 — 10y
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. infalliblelemon 145 — 10y
Ad

Answer this question