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

what does this mean? i am trying to make a regional fog local script but it just wont work

i am using this script with a part in the exact spot its looking for

local Lighting = game:GetService("Lighting")

local detectionPart = game.Workspace.FogDetectionPart
local localPlayer = game.Players.LocalPlayer


local function enableFog()
	Lighting.FogEnd = 250
	Lighting.Brightness = 1
	Lighting.Ambient = Color3.fromRGB(100, 100, 100)
	Lighting.OutdoorAmbient = Color3.fromRGB(50, 50, 50)
	game.Lighting:SetMinutesAfterMidnight(300)
end

local function disableFog()
	Lighting.FogEnd = 100000
	Lighting.FogStart = 0
end

detectionPart.Touched:Connect(function()
	-- This is just to add a TouchInterest
end)

local touching = false

while true do
	local foundPlayer = false
	for i,v in ipairs(detectionPart:GetTouchingParts()) do
		if v.Parent.Name == localPlayer.Name then
			foundPlayer = true
		end
	end

	if touching and not foundPlayer then
		-- Player is no longer in detection part
		disableFog()
		touching = false
	end

	if not touching and foundPlayer then
		-- Player is now in detection part and wasn't before
		enableFog()
		touching = true
	end

	wait(.5)
end

but it keeps giving me the error of

FogDetectionPart is not a valid member of Workspace "Workspace"

i dont know what this means, someone help please

1 answer

✓ Accepted answer

It's saying it can't find the part in workspace. Try waiting for the part to load in:

--line 3
local detectionPart = game.Workspace:WaitForChild("FogDetectionPart")

If that doesn't work then the part is probably parented to something else.

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