local UIbutton = returned[2]:WaitForChild(returned[3])
if UIbutton ~= nil then
print("it is not nil!")
end
UIbutton.MouseButton1Click:Connect(function()
print("clicked function running")
end)
It is not nil, but I don’t see any printed statement in the output stating “clicked function running”.
At this point I am going to try random things to see if they work.
Full new script:
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local character = plr.Character or plr.CharacterAdded:Wait()
local tabl = {
[1] = {
"Well, well, well. Look who we have here. A newbie!",
function()
return {"click"}
end,
false,
"Click to continue."
},
[2] = {
"You probably are wondering why you are here. You need to complete the tutorial!",
function()
return {"click"}
end,
false,
"Click to continue."
},
[3] = {
"First off, you need to claim a plot. Touch the yellow button to claim a plot.",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Essentials.Claim}
end,
false,
"Claim a plot to continue."
},
[4] = {
"Great job! Now, you must buy a conveyor. This is essential to your tycoon.",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Buttons.Create["Buy Conveyor - $1K"].Button}
end,
false,
"Buy a conveyor to continue."
},
[5] = {
"Awesome! Buy a chocoblox seller so when chocoblox is dropped it can be sold for cash!",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Buttons.Create["Buy Chocoblox Seller - $500"].Button}
end,
false,
"Buy a chocoblox seller to continue."
},
[6] = {
"Now you can buy a chocoblox machine that drops chocoblox. The chocoblox will move along the conveyor, eventually being sold.",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Buttons.Create["Buy Chocoblox Machine - $500"].Button}
end,
false,
"Buy a chocoblox machine to continue."
},
[7] = {
"Chocoblox is dropping, but how do you collect cash? You can collect cash by touching a green part. But where is it?",
function()
return {"click"}
end,
false,
"Click to continue."
},
[8] = {
"Try finding it, and when you find it, touch it and collect it!",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Essentials.GetCash.GetCash}
end,
false,
"Collect some cash to continue."
},
[9] = {
"Once you have enough cash, you can buy more machines!",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Buttons.Create["Buy Chocoblox Machine - $750"].Button}
end,
false,
"Buy two more machines to continue.",
function() --exception
if plr.leaderstats.Cash.Value >= 750 then
return true
else
return false
end
end
},
[10] = {
"Now, buy some walls so I can show you something amazing...",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Buttons.Create["Buy Walls - $100"].Button}
end,
false,
"Buy walls to continue.",
function() --exception
if plr.leaderstats.Cash.Value >= 100 then
return true
else
return false
end
end
},
[11] = {
"Woah, what is that red button?! Touch it, and something marvelous will happen...",
function()
return {"touch",workspace.Tycoon.Plots.Plot1.Buttons.Destroyed["Make Doorways"].Button}
end,
false,
"Touch the red button to continue."
},
[12] = {
"You see what happened? Blue buttons create, while red buttons destroy.",
function()
return {"click"}
end,
false,
"Click to continue."
},
[13] = {
"A gray button has appeared! These buttons allow you to choose what you want to buy. You can sell the item you buy and get a more expensive item. For now just buy the SmallMachine1.",
function()
return {"uiclick",plr.PlayerGui.ChooseButton.Frame.Purchase,"SmallMachine1"}
end,
false,
"Buy SmallMachine1 to continue.",
function() --exception
if plr.leaderstats.Cash.Value >= 1000 then
return true
else
return false
end
end
},
[14] = {
"When you have enough money, you can sell the machine and buy it again!",
function()
return {"uiclick",plr.PlayerGui.DeleteObject.Frame.Yes}
end,
false,
"Get $2250 then sell the machine to continue.",
function() --exception
if plr.leaderstats.Cash.Value >= 2250 then
return true
else
return false
end
end
},
[15] = {
"Buy MediumMachine1 now!",
function()
return {"touch",plr.PlayerGui.ChooseButton.Frame.Purchase,"MediumMachine1"}
end,
false,
"Buy MediumMachine1 to continue.",
function() --exception
if plr.leaderstats.Cash.Value >= 2250 then
return true
else
return false
end
end
},
[16] = {
"Awesome work! You can now teleport to the game.",
function()
return {"click"}
end,
false,
"blah continue."
},
}
local clickDebounce = false
game.ReplicatedStorage.Remotes.Functions.CheckTutorial.OnClientInvoke = function(value)
if script.Parent.Parent.Current.Value == value then
return true
else
return false
end
end
script.Parent.Parent.Current.Changed:Connect(function(value)
if tabl[value] then
if tabl[value + 1] ~= nil then
if not tabl[value][3] then
script.Parent.Text = tabl[value][1]
script.Parent.Parent.Info.Text = tabl[value][4]
local returned = tabl[value][2]()
if returned[1] == "click" then
print "click"
mouse.Button1Up:Connect(function()
if tabl[value][3] == false then
if tabl[value][5] then
if tabl[value][5]() == true then
if clickDebounce == false then
clickDebounce = true
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
wait(0.25)
clickDebounce = false
end
end
else--do the same thing
if clickDebounce == false then
clickDebounce = true
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
wait(0.25)
clickDebounce = false
end
end
end
end)
elseif returned[1] == "touch" then
print "touch"
if returned[2] and returned[2]:IsA("BasePart") then
print "basepart"
returned[2].Touched:Connect(function(hit)
if tabl[value][3] == false then
if tabl[value][5] then
if tabl[value][5]() == true then
if clickDebounce == false then
clickDebounce = true
print "touched"
if hit.Parent:FindFirstChild("Humanoid") then
print "plr"
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
end
wait(0.25)
clickDebounce = false
end
end
else--do the same thing
if clickDebounce == false then
clickDebounce = true
print "touched"
if hit.Parent:FindFirstChild("Humanoid") then
print "plr"
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
end
wait(0.25)
clickDebounce = false
end
end
end
end)
end
elseif returned[1] == "uiclick" then
print "uiclick"
if returned[2] then
print "returned"
if returned[2]:IsA("GuiButton") then
print "2 is guibutton"
returned[2].MouseButton1Click:Connect(function()
print "activated"
if tabl[value][3] == false then
if tabl[value][5] then
if tabl[value][5]() == true then
if clickDebounce == false then
clickDebounce = true
print "button clicked"
print "plr"
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
wait(0.25)
clickDebounce = false
end
end
else--do the same thing
if clickDebounce == false then
clickDebounce = true
print "button clicked"
print "plr"
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
wait(0.25)
clickDebounce = false
end
end
end
end)
elseif returned[3] then
-- print(returned[3])
local UIbutton = returned[2]:WaitForChild(returned[3])
if UIbutton ~= nil then
print("it is not nil!")
end
UIbutton.MouseButton1Click:Connect(function()
print("clicked function running")
end)
UIbutton.MouseButton1Up:Connect(function()
print("clickity clackity")
if tabl[value][3] == false then
if tabl[value][5] then
if tabl[value][5]() == true then
if clickDebounce == false then
clickDebounce = true
print "button clicked"
print "plr"
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
wait(0.25)
clickDebounce = false
end
end
else--do the same thing
if clickDebounce == false then
clickDebounce = true
print "button clicked"
print "plr"
wait(.15)
script.Parent.Parent.Current.Value += 1
tabl[value][3] = true
wait(0.25)
clickDebounce = false
end
end
end
end)
end
end
else
print "none"
end
end
elseif tabl[value + 1] == nil then
script.Parent.Parent.Info.Visible = false
script.Parent.Text = tabl[value][1]
script.Parent.Parent.Teleport.Visible = true
end
end
end)
wait(3)
script.Parent.Visible = true
script.Parent.Parent.Info.Visible = true
script.Parent.Parent.Current.Value = 1