When I press play, I see how much printed lines there are and if it shows like 3 I can see the 4th print and check what’s wrong. But in this case, there is a problem. I am using Flood escape 2’s button function. One line of code went wrong. I used my trick, and they only printed 6 lines of “tpa”. Here is the script:
local function check(m)
print("tpa")
local cbutton = m.Buttons:FindFirstChild("Button_"..currentbutton.Value)
print("tpa")
if cbutton:FindFirstChild("_Fade") then
print("tpa")
spawn(function()
print("tpa")
fade(m)
print("tpa")
end)
print("tpa")
elseif cbutton:FindFirstChild("_Appear") then
print("tpa")
spawn(function()
print("tpa")
appear(m)
print("tpa")
end)
print("tpa")
elseif cbutton:FindFirstChild("_Unanchor") then
print("tpa")
spawn(function()
print("tpa")
appear(m)
print("tpa")
end)
end
end
I’m not entirely sure what you are trying to do ( achieve overall) but if you were to replace your elseifwith normal If statements then that should fix the problem:
Example
local function check(m)
print("tpa")
local cbutton = m.Buttons:FindFirstChild("Button_"..currentbutton.Value)
print("tpa")
if cbutton:FindFirstChild("_Fade") then
print("tpa")
spawn(function()
print("tpa")
fade(m)
print("tpa")
end)
print("tpa")
end
if cbutton:FindFirstChild("_Appear") then
print("tpa")
spawn(function()
print("tpa")
appear(m)
print("tpa")
end)
print("tpa")
end
if cbutton:FindFirstChild("_Unanchor") then
print("tpa")
spawn(function()
print("tpa")
appear(m)
print("tpa")
end)
end
end
I don’t know if I’m a fan of ‘The Printing Advice’… Sure, you can see how many lines it executes, but you can’t see where your code actually goes. Wouldn’t it instead be more advantageous to instead add print where it actually matters, and have the message that’s sent to output be relevant to where the code reached? And it’s worth noting that ROBLOX does of course have a built in debugger… https://developer.roblox.com/en-us/articles/Lua-debugger
In reguards to your question, it may be of help if we had the code behind the “appear” and “fade” functions. As well as some additional context on the code’s intent.
local function fade(map)
local interactive = map.Interactives:FindFirstChild("Interactive_"..currentbutton.Value)
interactive.Transparency = 1
interactive.CanCollide = false
end
local function appear(map)
local interactive = map.Interactives:FindFirstChild("Interactive_"..currentbutton.Value)
interactive.Transparency = 0
interactive.CanCollide = true
end
Do any of the things you are trying to find using FindFirstChild return false or nil? , it should work I believe, as long as there are no errors and the things you are trying to reference exist.
That’s weird, also now that I understand (after re-reading your post/code) what you are trying to do the if statements probably aren’t super important ( elseif is fine, assuming that one value is in cbutton at one time).
However Quick question, Are the fade and appear functions running at all?
Also if the “_Fade” value or whatever doesn’t exist adding some wait for childs might be to your benefit (depending wether you are fine with the function yielding)
local function fade(map)
local interactive = map.Interactives:FindFirstChild("Interactive_"..currentbutton.Value)
interactive.Transparency = 1
interactive.CanCollide = false
end
local function appear(map)
local interactive = map.Interactives:FindFirstChild("Interactive_"..currentbutton.Value)
interactive.Transparency = 0
interactive.CanCollide = true
end
local function unanchor(map)
local interactive = map.Interactives:FindFirstChild("Interactive_"..currentbutton.Value)
interactive.Anchored = false
wait(map.Buttons:FindFirstChild("Button_"..currentbutton.Value)._Unanchor.Delay.Value)
interactive.Transparency = 1
interactive.CanCollide = false
end
local function check(m)
print("tpa")
local cbutton = m.Buttons:FindFirstChild("Button_"..currentbutton.Value)
print("tpa")
if cbutton:FindFirstChild("_Fade") then
print("tpa")
spawn(function()
print("tpa")
fade(m)
print("tpa")
end)
print("tpa")
end
if cbutton:FindFirstChild("_Appear") then
print("tpa")
spawn(function()
print("tpa")
appear(m)
print("tpa")
end)
print("tpa")
end
if cbutton:FindFirstChild("_Unanchor") then
print("tpa")
spawn(function()
print("tpa")
appear(m)
print("tpa")
end)
end
end