local Part = game.Workspace.Part function onOne() onTwo() Part.Transparency = 1 end function onTwo() wait(1) Part.Transparency = 0 end onOne()
Ofcourse, when you call function onTwo, onOne stops. What I want to know is: How can I call onTwo and continue onOne?
ClickBrick
and ChangeColour
. When clicked on the ClickBrick
it will result in printing, "Brick is Clicked"
. Then when clicked on the ChangeColour
Brick, the brick will change into red colour.ChangeColour
Brick first, it will not change its colour because it is inside the Click Brick
's code.-- Declaration Section --//Game Services local Workspace = game:GetService("Workspace") --//Assets local button = Workspace:WaitForChild("ClickBrick") local ColourChanger = Workspace:WaitForChild("ChangeColour") -- Processing Section changePartColour = function() print("It is clicked!") local function changeBrickColour () ColourChanger.BrickColor = BrickColor.Red() print("Changed to red colour!") end ColourChanger.ClickDetector.MouseClick:Connect(changeBrickColour) --You don't need to connect it here, you can also connect it in line 13. print("Continue your code below here.") wait(5) ColourChanger.BrickColour = BrickColor.Gray() end button.ClickDetector.MouseClick:Connect(changePartColour)
Spawn
is used to embed another function inside a function-- Processing Section local function PrintSomeText() spawn(PrintText) print("This printed") end local function PrintText () wait(1) print("Hello World!") end PrintSomeText()
The onTwo function has a wait inside, so you should spawn it. Let me give you the fixed code:
local Part = game.Workspace.Part function onOne() spawn(onTwo) Part.Transparency = 1 end function onTwo() wait(1) Part.Transparency = 0 end onOne()