So, I've been making a game where the fog changes after you go through an invisible part. here's what I got so far
function onTouched(hit)
game.Lighting.FogColor = Color3.new(0, 0, 0)
game.Lighting.FogEnd = 100
end
script.Parent.Touched:connect(onTouched)
Is there a way to make it so this only affects players who touch the block? If it helps, you can't exit the area with this code :) Thanks
Alright so you're gonna have to insert a remote into ReplicatedStorage. Name the remote event "CreateFog".
Insert a Script into the part you want to be touched to create the fog and paste the following script into the Script
local Touched Touched = script.Parent.Touched:Connect(function(hit) if not hit.Parent:FindFirstChild("HumanoidRootPart") then return end local target = hit.Parent game.ReplicatedStorage.CreateFog:FireClient(game.Players:GetPlayerFromCharacter(target)) end)
After you're finished with the script, insert a LocalScript into StarterPlayerScripts and paste the following script into the LocalScript
game.ReplicatedStorage.CreateFog.OnClientEvent:Connect(function() local Lighting = game:GetService("Lighting") Lighting.FogColor = Color3.new(0, 0, 0) Lighting.FogEnd = 100 end)
This was tested and it works.