Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help With Userdata Value being String Values?

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

✓ Accepted answer

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.