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

How can you clone using TextButtons?

Asked by 10 years ago

Hey guys, and thank you very much for helping me out a little while ago (Whomever you were). Now, while I was building, I caught a problem that I could not figure out how to solve. How would you clone a tool named "Sword" in Lighting into a player's Backpack when the player clicks on a Gui TextButton? The following script is placed inside the TextButton, but it will not work. Again if you can, please help me. Thank you VERY much for spending your time to correct my errors.

function mouseclick(player)
    if player.Backpack:FindFirstChild("Sword") then
        script.Parent.Text = "Already owned"
        wait(1)
        script.Parent.Text = "1000 $"
        else
        game.Lighting.Uzi:Clone().Parent = player.Backpack
        script.Parent.Text = "BOUGHT"
        wait(1)
        script.Parent.Text = "1000 $"
    end
end
script.Parent.MouseButton1Down:connect(mouseclick)

1 answer

Log in to vote
0
Answered by 10 years ago

Try this. I never tried this, but I saw some errors.

function mouseclick(player)
    if (player.Backpack.Sword ~= nil) then --[[I'm guessing this is where the error was. BTW your searching for something that doesn't have any spaces, so why would u need to use FindFirstChild. Plus in this situation, I think it might make more errors.]]
        script.Parent.Text = "Already owned"
        wait(1)
        script.Parent.Text = "1000 $"
        else
        game.Lighting.Uzi:Clone().Parent = player.Backpack --Uzi? at line 2 it said Sword.
        script.Parent.Text = "BOUGHT"
        wait(1)
        script.Parent.Text = "1000 $"
    end
end
script.Parent.MouseButton1Down:connect(mouseclick)
0
Your script didn't work, but it inspired me to make another idea that did work. So... Thanks! dpark19285 375 — 10y
0
K :3 EzraNehemiah_TF2 3552 — 10y
Ad

Answer this question