Categories > Coding > Lua >

Unable to cast value to Object?

Posts: 20

Threads: 13

Joined: Jun, 2023

Reputation: 0

Posted

What i'm doing wrong?

If i just print  GetChildren():
https://i.imgur.com/gZqCSMX.png


But then i try to do: And i got error. Why?(Path Folder contain Frames)
https://i.imgur.com/cEGfWAN.png

local Folder = PathToFolder:GetChildren()
						for i, value in ipairs(Folder ) do
							local args = {
								[1] = {
									[1] = value.Name
								}
							}
							game:GetService("ReplicatedStorage").craft:InvokeServer(unpack(args))
						end
  • 0

Posts: 206

Threads: 9

Joined: Feb, 2023

Reputation: 5

Replied

The format almost made me cry, I've rewritten your code, let me know if it works.

 

local Folder = workspace.Folder:GetChildren()
local Craft  = game:GetService("ReplicatedStorage").craft

for __,v in next, Folder do
    if v:IsA("Frame") then
        local args = {
            [1] = {
                [1] = v.Name
            }
        }
        Craft:InvokeServer(unpack(args))
    end
end
  • 0

https://media.discordapp.net/attachments/1134643100715855893/1138795549244539011/SiggyOnGod.png

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )