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

A script that's supposed to give items is not working? [Answered]

Asked by 8 years ago

I made a little script where you click a button then you get some tools. But, the problem is that the tools aren't appearing in the player's backpack! This problem has happend before to me aswell..

script.Parent.MouseButton1Click:connect(function()
    local move1 = script.Parent.Weapon
    local move2 = script.Parent.Weapon2
    local moveStorage = workspace.Moves
    local plr = script.Parent.Parent.Parent.Parent.Parent.Parent

    local one = moveStorage:FindFirstChild(move1.Value):Clone()
    local two moveStorage:FindFirstChild(move2.Value):Clone()
    one.Parent = plr.Backpack
    two.Parent = plr.Backpack
end)

Okay I fixed the problem with the 2nd move. I needed an =. It apparently just works online, thought move2 doesn't get cloned now...

0
Most likely a problem with the Hierarchy. Check line 5 and to see if it actually returns the Player. UserOnly20Characters 890 — 8y
0
it doesnt... Operation_Meme 890 — 8y
0
WELL! FOR SOME WEIRD REASON, IT ONLY WORKS ONLINE! YAY.. Operation_Meme 890 — 8y
0
except move2 doesn't get cloned Operation_Meme 890 — 8y

1 answer

Log in to vote
0
Answered by
azabat 10
8 years ago
script.Parent.MouseButton1Click:connect(function()
    local move1 = script.Parent.Weapon
    local move2 = script.Parent.Weapon2
    local moveStorage = workspace.Moves
    local plr = script.Parent.Parent.Parent.Parent.Parent.Parent

    local one = moveStorage:FindFirstChild("Weapon"):Clone() -- Changed value to weapon name
    local two moveStorage:FindFirstChild("Weapon2"):Clone() -- Ditto.
    one.Parent = plr.Backpack
    two.Parent = plr.Backpack
end)

I'm not sure if your move1 and move2 are values? If they are, then you can use move1.Value. If they're items/objects, you can use move1.Name and move2.Name.

0
they're values. Operation_Meme 890 — 8y
Ad

Answer this question