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

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

Asked by
harstud 218 Moderation Voter
4 years ago

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.
0
Have you set the MinigameKit's parent to the script? If it isn't, that's why it's nil. KingDomas 153 — 4y
0
The MinigameKit's Parent is the script. @KingDamas harstud 218 — 4y
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 firestarroblox123 440 — 4y
0
How am I meant to make it into a model? harstud 218 — 4y

1 answer

Log in to vote
1
Answered by
NotedAPI 810 Moderation Voter
4 years ago
Edited 4 years ago

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)
0
How do I do this? harstud 218 — 4y
0
You can do this by using the InsertService. NotedAPI 810 — 4y
0
I will update my answer with a script NotedAPI 810 — 4y
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. harstud 218 — 4y
Ad

Answer this question