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

Fog not darkening?

Asked by 9 years ago

I'm using a normal script inside of a part to make the game's Fog turn to black. What am I doing wrong here?

    local OtherworldPart = script.Parent
local DarkenFog = game.Lighting.FogColor

function onTouch(part)
    local otherworldGui = Instance.new("ScreenGui")
        otherworldGui.Parent = game.Players.LocalPlayer.PlayerGui
    local otherworldText = Instance.new("TextLabel")
        otherworldText.Parent = otherworldGui
        otherworldText.Position = UDim2.new(0,0,0,0)
        otherworldText.Size = UDim2.new(0,200,0,50)
        otherworldText.BackgroundTransparency = 1
        function FogColor()
            game.Lighting.FogColor = FogColor.Value
            wait()
        end
        otherworldText.Text = "That's strange. It's getting darker."
        otherworldText.Font = Enum.Font.SourceSansBold
        otherworldText.FontSize = Enum.FontSize.Size36
        otherworldText.TextColor = BrickColor.new(255,255,255)
        otherworldText.TextStrokeTransparency = 0
for i = 0, 1, .1 do
        otherworldText.TextTransparency = i
        wait(0.1)
        end
    end

OtherworldPart.Touched:connect(onTouch)

EDIT: Posted the full script

0
Is this the full script? Discern 1007 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You're creating a function that you do not fire, which means that the fog will not be set. Also, the function is unnecessary as you could just set the FogColor in the code without the function.

Also, I'm not sure what the FogColor variable is so I'm going to assume that you've set the variable already. If you haven't set the FogColor variable, make sure you set that also, otherwise the FogColor will not change and the script will error.


Code:

local OtherworldPart = script.Parent
--No need for DarkenFog here.

function onTouch(part)
    local otherworldGui = Instance.new("ScreenGui")
        otherworldGui.Parent = game.Players.LocalPlayer.PlayerGui
    local otherworldText = Instance.new("TextLabel")
        otherworldText.Parent = otherworldGui
        otherworldText.Position = UDim2.new(0,0,0,0)
        otherworldText.Size = UDim2.new(0,200,0,50)
        otherworldText.BackgroundTransparency = 1
    game.Lighting.FogColor = FogColor.Value
        otherworldText.Text = "That's strange. It's getting darker."
        otherworldText.Font = Enum.Font.SourceSansBold
        otherworldText.FontSize = Enum.FontSize.Size36
        otherworldText.TextColor = BrickColor.new(255,255,255)
        otherworldText.TextStrokeTransparency = 0
    for i = 0, 1, .1 do
            otherworldText.TextTransparency = i
            wait(0.1)
    end
end

OtherworldPart.Touched:connect(onTouch)

I hope my answer helped you. If it did, be sure to accept it.

Ad

Answer this question