I've had some people help my errors but one error I have not been able to fix. The code below is a game where when a player presses a button 1 of 2 things will happen, 1 is it will go foggy, the other is it will be low gravity. The problem is that when it has been 12 seconds of low gravity I wanted everything to go back to normal (the button being visible, the gravity being normal again ect) the problem is that it seems correct but after waiting 12 seconds on line 27 it will not run the code that makes it back to normall , it will just stay the same (in low gravity) the script is the child of the button that they press, it is inside a normall script, could anyone help me out? Thank you!

 -- variables
local lighting = game.Lighting
local button = script.Parent
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = button
ClickDetector.MaxActivationDistance = 15
	
	-- functions
	
function Gravity()
	game.Workspace.Gravity = 30
	game.Workspace.World.BrickColor = BrickColor.new("Mid gray")
	game.Workspace.SA.Transparency = 0
	game.Workspace.SA.CanCollide = true
	game.Workspace.SpaceRock.Transparency = 0
	game.Workspace.SpaceRock.CanCollide = true
	game.Workspace.Z.Transparency = 0
	game.Workspace.Z.CanCollide = true
	game.Workspace.SRock.Transparency = 0
	game.Workspace.SRock.CanCollide = true
	game.Workspace.L.Transparency = 0
	game.Workspace.L.CanCollide = true
	game.Workspace.Y.Transparency = 0
	game.Workspace.Y.CanCollide = true
	lighting.TimeOfDay = 1

	wait(12)
	
	print("12 seconds")
	button.Transparency = 0
	button.CanCollide = true
	game.Workspace.Stand.Transparency = 0
	game.Workspace.Stand.CanCollide = true
	game.Workspace.Gravity = 128
	lighting.TimeOfDay = 14
end

local function InsideMouseClick()
    lighting.FogEnd = 1000
                button.CanCollide = true
                button.Transparency = 0
                game.Workspace.Stand.Transparency = 0
                game.Workspace.Stand.CanCollide = true
                game.Workspace.FindMe.CanCollide = false
	            game.Workspace.FindMe.Transparency = 1
	            game.StarterGui.ScreenGui.TextLabel.Visible = false
end

function Fog()
	lighting.FogEnd = 12
        game.StarterGui.ScreenGui.TextLabel.Visible = true	
		game.Workspace.FindMe.Transparency = 0
		game.Workspace.FindMe.CanCollide = true
		game.Workspace.FindMe.ClickDetector.MouseClick:Connect(InsideMouseClick)
	end
--main
ClickDetector.MouseClick:Connect(function()
	print("Button has been clicked.")
	button.Transparency = 1
	game.Workspace.Stand.Transparency = 1
	game.Workspace.Stand.CanCollide = false
	button.CanCollide = false
	wait(0.4)
	local variable = math.random(1, 2)
	if variable == 1 then
		lighting.FogEnd = 12
	else
		Gravity()
	end
end)

2 comments

0

Any error codes? Try setting the wait() to 1, so you don't have to wait that much (and you can change it back later).

0

i set it to 3 and it worked, any over though doesn't. There are no error mesages, thanks though.