So there was a problem in my game. So I made a flood escape 2 button system but the spawn function won’t function. The methods I do is adding return’s, removing local from local function but it won’t work. Any ideas would be helpful!
local currentbutton = script.OnButton
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)
local cbutton = m.Buttons:FindFirstChild("Button_"..currentbutton.Value)
if cbutton:FindFirstChild("_Fade") then
--spawn(function()
repeat wait()
fade(m)
until fade(m)
return
--end)
end
if cbutton:FindFirstChild("_Appear") then
--spawn(function()
repeat wait()
appear(m)
until appear(m)
return
--end)
end
if cbutton:FindFirstChild("_Unanchor") then
spawn(function()
repeat wait()
unanchor(m)
until unanchor(m)
return
end)
end
end
What i mean is, you need an Event, to fire all those functions, like:
local function whateveryouwant()
-- Do Something
end
local isHit = false
script.Parent.Touched:Connect(function(hit)
if isHit == false then
isHit = true
whateveryouwant()
end
end)
If you don’t know flood escape 2’s buttons, then I will be discussing it. So there are three or more buttons and they have a part. If they click a button, the part activated and the next button turns green. Also the button that just got pressed will turn red.