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

Help With Userdata Value being String Values?

Asked by
Scootakip 299 Moderation Voter
8 years ago

This script makes it so that whatever item you click on in your inventory, it moves to the first available section in your crafting values, but it's having some weird errors.

for i,ps in pairs(script.Parent:GetChildren()) do
    if ps.ClassName == "Frame" then
    ps.ImageButton.MouseButton1Click:connect(function(lol)
        local gunToGet = ps.Name
local didPlace = false;
local p = script.Parent.Parent.Crafting
for i=1, 4 do
    local v = p:FindFirstChild("Slot"..tostring(i)).."Val";
    if v then -- Let's not break your script if there's not 50 slots.
        if v.Value == "Empty" then
            v.Value = gunToGet; -- Give them the gun;
            didPlace = true;
            break; -- Stop looping
        end;
    end;
end;
if not didPlace then print "Full inv sorry m8" end;
    end)
    end
end

An error says that at line 8 " attempt to concatenate a userdata value" but it's just a string value? I don't understand why it's doing that. Help?

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

You are trying to concatenate the object, not the value of the object.

local v = p:FindFirstChild("Slot" .. tostring(i)).Value .. "Val";
Ad

Answer this question