Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Surface GUI Textbutton help?

Asked by 10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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 '<eof>'

Ad
Log in to vote
0
Answered by 10 years ago

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)

Answer this question