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

What am I doing wrong with my method of trying to equip into player backpack?

Asked by 9 years ago

My explorer set up can be found here: http://tinypic.com/r/2hg4x7b/9

NOTE : I have a script that puts the whole screen gui into the players.

name = script.Parent.Nam.Value
items = game.ServerStorage.Items


print(name)

script.Parent.MouseButton1Click:connect(function()
    local found = items:FindFirstChild(name)

    if found then
        print("works")--many attempts at this point but no solutions yet. I tried many like "that =                    
                        that." or "clone.parent stuff"










    end
end)

Hello. I'm practicing at the same time working on a game. What I did was that I inserted into one of the many frames so that you can click and it gives you an item like an inventory. So far I got a script to equip with q and a bunch of others like selection boxes. Now, I need to be able to take items out of the inventory and put into default roblox backpack. Thats what I am trying to do with this script. I'm trying to get the name value from a string value I put in one of the frames. That name value will determine what Item I get back. So if I want an item called gun the name value in the string value in the frame should match. So once the name value gets taken I want the script to look through a folder named items. In that folder is going to be my tools and stuff. I want the script to use the name value in the frame and use that to look for the same name in the items folder. IDK what I'm doing wrong in my script as i'm pretty stumped atm. Perhaps I'm making it harder for myself?

2 answers

Log in to vote
1
Answered by
Prioxis 673 Moderation Voter
9 years ago

not sure if the variable Nam is spelled like that on purpose but I'm just going to keep it that way

by the way I converted your global variables into local variables meaning they can only be accessed from this script and no other so the values won't get mixed up from other players scripts and potentially create duping.

local name = script.Parent.Nam.Value -- adding local before a variables makes it not a global variable and it won't get mixed up between other scripts
local items = game.ServerStorage.Items
local player = game.Players.LocalPlayer

print(name)

script.Parent.MouseButton1Click:connect(function()
    local found = items:FindFirstChild(name)

    if found then
            local c = found:Clone()
        c.Parent = player.Backpack










    end
end)


0
A global variable is made with _G.variable. Variables that lack local or _G are not global, but they are available at all scopes of the script they're within. Marios2 360 — 9y
0
@alextheotaku there are no errors but it doesnt seem to be putting the item into my backpack robloxiveboy 25 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

You spelled "Name" wrong on line 1.

Answer this question