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

why does this say "Tutorial is not a valid member of Workspace"?

Asked by 7 years ago
Edited 7 years ago
function menu()
local Cmenu = game.ReplicatedStorage.MainUI:Clone()
local Cmainspawn = game.ReplicatedStorage.Spawn:Clone()
local menu = game.ReplicatedStorage.MainUI
local player = game.Players.LocalPlayer
    local b2 = menu.Img.Holder.Holder.b2
    local c3 = menu.Img.Holder.Holder.c3
    local d4 = menu.Img.Holder.Holder.d4
    local e5 = menu.Img.Holder.Holder.e5
    local f6 = menu.Img.Holder.Holder.f6
    local g7 = menu.Img.Holder.Holder.g7
    local h8 = menu.Img.Holder.Holder.h8
    local i9 = menu.Img.Holder.Holder.i9
    local j10 = menu.Img.Holder.Holder.j10
    local k11 = menu.Img.Holder.Holder.k11
    local l12 = menu.Img.Holder.Holder.l12
if game.Workspace.Tutorial ~= nil then
Cmenu.Parent = player.PlayerGui
Cmainspawn.Parent = player.PlayerGui
game.Workspace.Tutorial:Destroy()
player.PlayerGui.FinishUI:Destroy()
player.PlayerGui.HUD:Destroy()
player:LoadCharacter()      
    elseif game.Workspace.Lvl1 ~= nil then
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
    Cmenu.Parent = player.PlayerGui
    Cmainspawn.Parent = player.PlayerGui
    game.Workspace.Lvl1:Destroy()
    player.PlayerGui.FinishUI:Destroy()
    player.PlayerGui.HUD:Destroy()
    player:LoadCharacter()
     elseif game.Workspace.Lvl2 ~= nil then
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl3 ~= nil then
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl4 ~= nil then
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl5 ~= nil then
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl6 ~= nil then
    g7.Img.Visible = false
    g7.TextButton.LocalScript.Disabled = false
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl7 ~= nil then
    h8.Img.Visible = false
    h8.TextButton.LocalScript.Disabled = false
    g7.Img.Visible = false
    g7.TextButton.LocalScript.Disabled = false
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl8 ~= nil then
    i9.Img.Visible = false
    i9.TextButton.LocalScript.Disabled = false
    h8.Img.Visible = false
    h8.TextButton.LocalScript.Disabled = false
    g7.Img.Visible = false
    g7.TextButton.LocalScript.Disabled = false
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl9 ~= nil then
    j10.Img.Visible = false
    j10.TextButton.LocalScript.Disabled = false
    i9.Img.Visible = false
    i9.TextButton.LocalScript.Disabled = false
    h8.Img.Visible = false
    h8.TextButton.LocalScript.Disabled = false
    g7.Img.Visible = false
    g7.TextButton.LocalScript.Disabled = false
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl10 ~= nil then
    k11.Img.Visible = false
    k11.TextButton.LocalScript.Disabled = false
    j10.Img.Visible = false
    j10.TextButton.LocalScript.Disabled = false
    i9.Img.Visible = false
    i9.TextButton.LocalScript.Disabled = false
    h8.Img.Visible = false
    h8.TextButton.LocalScript.Disabled = false
    g7.Img.Visible = false
    g7.TextButton.LocalScript.Disabled = false
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false
     elseif game.Workspace.Lvl11 ~= nil then
    l12.Img.Visible = false
    l12.TextButton.LocalScript.Disabled = false
    k11.Img.Visible = false
    k11.TextButton.LocalScript.Disabled = false
    j10.Img.Visible = false
    j10.TextButton.LocalScript.Disabled = false
    i9.Img.Visible = false
    i9.TextButton.LocalScript.Disabled = false
    h8.Img.Visible = false
    h8.TextButton.LocalScript.Disabled = false
    g7.Img.Visible = false
    g7.TextButton.LocalScript.Disabled = false
    f6.Img.Visible = false
    f6.TextButton.LocalScript.Disabled = false
    e5.Img.Visible = false
    e5.TextButton.LocalScript.Disabled = false
    d4.Img.Visible = false
    d4.TextButton.LocalScript.Disabled = false
    c3.Img.Visible = false
    c3.TextButton.LocalScript.Disabled = false
    b2.Img.Visible = false
    b2.TextButton.LocalScript.Disabled = false


end
end

script.Parent.MouseButton1Click:connect(menu)

I want it to check if Tutorial is in workspace, if it isn't I want it to check for Lvl1 and so on.

Note: This is a LocalScript

0
Use a waitforchild() if its not finding it. GuestRealization 102 — 7y
0
I did that, but it just says infinite yield Noxility -4 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

If "Tutorial" is in workspace:

if workspace:FindFirstChild("Tutorial") then

If "Tutorial" is not in workspace:

if not workspace:FindFirstChild("Tutorial") then

Pretty simple eh

0
or of course ` if (workspace:FindFirstChild("Tutorial")) then ... else ... end ` plasma_node 343 — 7y
0
Yes. Programical 653 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

You need to use this:

local Example = game.Workspace:FindFirstChild('Tutorial')

if Example then
    -- This is where you would put the code if it's there
else
    -- This is where you would do another FindFirstChild() function.
end
0
Use workspace:WaitForChild('Tutorial') that might work 4D_X 118 — 7y

Answer this question