Error "Invalid argument #3 (Instance expected, got userdata)"

Hello.

I’m using ro-strap and I am trying to create an imagelabel instance and set it’s parent to a frame. This is the code I have, and I get an error as said in the title, “Invalid argument #3 (Instance expected, got userdata)” on the bottom line. (Image.Parent = Flat)

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Resources = require(ReplicatedStorage:WaitForChild("Resources"))
local Color = Resources:LoadLibrary("Color")
local PseudoInstance = Resources:LoadLibrary("PseudoInstance")
local LocalPlayer repeat LocalPlayer = Players.LocalPlayer until LocalPlayer or not wait()
local PlayerGui repeat PlayerGui = LocalPlayer:FindFirstChildOfClass("PlayerGui") until PlayerGui or not wait()

local Screen = Instance.new("ScreenGui", PlayerGui)

local Frame = Instance.new("Frame", Screen)
Frame.BackgroundTransparency = 1
Frame.BorderSizePixel = 0
Frame.Size = UDim2.new(0, 1022, 0, 784)
Frame.Position = UDim2.new(0, 0, 0, 0)

local Flat = PseudoInstance.new("RippleButton")
Flat.Size = UDim2.new(0, 50, 0, 50)
Flat.Position = UDim2.new(0.017, 0, 0.355, 0)
Flat.PrimaryColor3 = Color3.fromRGB(255, 255, 255)
Flat.BorderRadius = 4
Flat.Style = "Contained"
Flat.Font = "GothamBold"
Flat.Parent = Frame

local Image = Instance.new("ImageLabel")
Image.Size = UDim2.new(0, 50, 0, 50)
Image.BackgroundTransparency = 1
Image.BorderSizePixel = 0
Image.Image = "rbxassetid://5918968480"
Image.Parent = Flat

Does anyone know what I am doing wrong?

This script doesn’t even have 35 lines in it. Please show us the full error and stack trace and mark the line that is erroring with a comment.
Oh nevermind I see where you said it. Flat is a ‘pseudoinstance’, which is something I can’t help you with sicne I don’t know what the module looks like. It needs to be a regular Roblox instance. Check the docs for that module if it comes with them.

1 Like

Sorry, just realised, I deleted spaces because when pasted it added a space between each line, it is the bottom line, where it says Image.Parent = Flat

1 Like

Glad you’re looking for help, but please move your post to #help-and-feedback:scripting-support instead of using #resources:community-resources. You can change this by editing your post.

1 Like

Omg, sorry, I thought this was scripting support.

Also when I saw your script this caught my attention:

Instead of this you should try using Enum. For example:

Flat.Font = Enum.Font.GothamBold
1 Like

Since you are using RoStrap, you would have to access the actual object by doing Flat.Object.

local Image = Instance.new("ImageLabel")
Image.Size = UDim2.new(0, 50, 0, 50)
Image.BackgroundTransparency = 1
Image.BorderSizePixel = 0
Image.Image = "rbxassetid://5918968480"
Image.Parent = Flat.Object -- instead of Flat
2 Likes

Thank you very much! I appreciate it.