FogEnd not applying Ingame

So I have this script:

FogLayer.Touched:Connect(function(other)
	local humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
	if humanoid and other:IsA("Part") then
		Lighting.FogEnd = 100
	end
end)

if the player touches the part it changes the Lighting.FogEnd Normally but it’s not applying I don’t see the game getting darker

1 Like

Do you have an Atmosphere inside the Lighting?

Use this script, i test in studio and it works.

local Lighting = game:GetService("Lighting")
local Part = script.Parent -- Your Part

Part.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChildOfClass("Humanoid") then
		Lighting.FogEnd = 100
	end
end)

Also make sure you enabled “CanTouch” option in part.

It doesn’t work because you are checking if a thing that touched the FogLayer is a Part, parts of the character are MeshPart’s so checking if they are Part’s wont work. Instead you can check if its a MeshPart or BasePart (which includes both MeshPart’s and Part’s).

I mean, when the player touches the part, it changes the number in the lightning.
image
As I can see, the number changes, but the problem with the applying It doesn’t apply; it just changes the number, but it does not get darker.

The only Part within a character is HumanoidRootPart meaning if your legs touch the part nothing will happen (in general its enough to just check for a Humanoid).
Are you sure you haven’t added something to the Lighting that could be messing with it? Try it in an empty baseplate (without Atmosphere in the Lighting) as it should work there. Make sure you don’t have any plugins or scripts that could be affecting the lighting.

I figured out what was the problem, so the problem is not with the part; it’s with the Roblox terrain water. I forgot to mention that the part is inside the water, so when the FogEnd changes, it will not feel dark underwater, but when you exit the water, it will look dark. Do you know how I can fix it so it looks dark underwater?

I don’t think there’s a way to render normal fog underwater, however water does have Transparency and if you set it to a low number like 0.02 you should get the desired effect.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.