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

Error Mini Ware.lua:6: attempt to index nil with 'WaitForChild'?

So I am currently making a plugin for my game, Mini Ware! And this error ( Mini Ware.lua:6: attempt to index nil with 'WaitForChild') keeps appearing when I press the Minigame Kit button, there is a model inside the script with the Minigame Kit but I just don't know what's causing it or how to fix it. Thanks.

local PluginToolbar = plugin:CreateToolbar("Mini Ware!")
local MenuButton = PluginToolbar:CreateButton("Menu", "Shows the menu for help and more.", "rbxassetid://4535959292")
local MingameKitButton = PluginToolbar:CreateButton("Minigame Kit", "Creates a minigame kit.", "rbxassetid://6620816")

MingameKitButton.Click:Connect(function()
	local MinigameKit = script:WaitForChild("MinigameKit"):Clone()
	MinigameKit.Parent = workspace
end)
-- Also, this is all I have done so far.

4 comments

0

Have you set the MinigameKit's parent to the script? If it isn't, that's why it's nil.

0

The MinigameKit's Parent is the script. @KingDamas

1

I would suggest making the plugin a model, and then do like script.Parent:WaitForChild("MinigameKit") although I do not know if it would fix anything

0

How am I meant to make it into a model?

1 answer

✓ Accepted answer

I'm pretty sure because script doesn't exist. You would have to insert the model from the script and just set the parent to workspace if it isn't already.

local PluginToolbar = plugin:CreateToolbar("Mini Ware!")
local MenuButton = PluginToolbar:CreateButton("Menu", "Shows the menu for help and more.", "rbxassetid://4535959292")
local MingameKitButton = PluginToolbar:CreateButton("Minigame Kit", "Creates a minigame kit.", "rbxassetid://6620816")
local insertService = game:GetService("InsertService")


MingameKitButton.Click:Connect(function()
	local NewModel = insertService:LoadAsset(MODEL ID HERE)
	NewModel.Parent = workspace
end)

4 comments

0

How do I do this?

0

You can do this by using the InsertService.

0

I will update my answer with a script

0

Thank you, but I have already gathered up an answer by putting the resources and script into the model. I will accept your answer though.

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