Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Surface GUI Textbutton help?

I'm a 1-2/10 scripter so I'm still trying to learn but I'm stuck on this, I looked around and couldn't find anything that helpful.

enabled = true

script.Parent.TextButton.MouseButton1Click:connect(function()
	if enabled then -- NIGHT TIME
		game.Lighting.TimeOfDay = "20:00:00"
		game.Lighting.OutdoorAmbient = Color3.new(0.395,0.395,0.395)
		game.Lighting.Brightness = 0.5
		game.Lighting.FogColor = Color3.new(0.0395,0.0395,0.120)
		game.Lighting.FogEnd = 1000
		enabled = false
	else -- DAY TIME
		game.Lighting.TimeOfDay = "15:00:00"
		game.Lighting.OutdoorAmbient = Color3.new(0.5,0.5,0.5)
		game.Lighting.Brightness = 1
		game.Lighting.FogColor = Color3.new(0.749,0.749,0.749)
		game.Lighting.FogEnd = 2500
		enabled = true
	end
end

I want the SurfaceGUI Textbutton to be clicked to change the day. It works if I use a regular block but I want it on a SurfaceGUI and i'm having trouble. Can anyone help fix this? Really helpful if anyone could clarify this for me!

2 answers

✓ Accepted answer

The only problem with the posted snippet is that you are missing a parenthesis after the final end to match the parenthesis on line 3.

I tested the script and it worked perfectly fine! So maybe that syntax error was your issue.

If that is the case then you should use your output. It would have told you that:

Workspace.Part.SurfaceGui.Script:19: ')' expected (to close '(' at line 3) near ''

I polished it up a bit and it works now, thanks!

enabled = true

function Solar()
	if enabled then -- NIGHT TIME
		game.Lighting.TimeOfDay = "20:00:00"
		game.Lighting.OutdoorAmbient = Color3.new(0.395,0.395,0.395)
		game.Lighting.Brightness = 0.5
		game.Lighting.FogColor = Color3.new(0.0395,0.0395,0.120)
		game.Lighting.FogEnd = 1000
		enabled = false
	else -- DAY TIME
		game.Lighting.TimeOfDay = "15:00:00"
		game.Lighting.OutdoorAmbient = Color3.new(0.5,0.5,0.5)
		game.Lighting.Brightness = 1
		game.Lighting.FogColor = Color3.new(0.749,0.749,0.749)
		game.Lighting.FogEnd = 2500
		enabled = true
	end
end

script.Parent.TextButton.MouseButton1Click:connect(Solar)

This discussion is preserved as it was. New answers, comments, and votes are closed.