How to make fog only for player that touched it?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

I want to make the part when you touch it only you will have fog 20

  1. What is the issue?

I don’t know how to make the fog only for you

  1. What solutions I tried so far?

I used this script already:

debounce = false

script.Parent.Touched:connect(function(hit)
	if not debounce then
		debounce = true
		if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
game.Lighting.FogEnd = 20
		end
		debounce = false
	end
end)

Thanks for every help!
vojtasuper2.

2 Likes

Convert this script to a LocalScript. Then it will only happen for each player on their own screen.
Also, the debounce is useless if there is no delay before making it false.

1 Like

You can approach this two ways. You can either change the RunContext for this script to client or use a RemoteEvent to fire an event to the client of the player which has touched this part to edit their fog.

1 Like

it’s not working even for player now.

1 Like

bro if you want it can be see for only a player who touchs it just use client script for make it

make remote event in ReplicatedStorage,local script in player’s character
server-side script

local Remote = game.ReplicatedStorage.RemoteEvent
local players = game:GetService("Players")
local part = script.Parent

players.PlayerAdded:Connect(function(ply)
	ply.CharacterAdded:Connect(function()
		Remote:FireClient(ply,part)
	end)
end)

client-side script

local Remote = game.ReplicatedStorage.RemoteEvent
local db = false
Remote.OnClientEvent:Connect(function(part)
	part.Touched:Connect(function(hit)
		local Humanoid = hit.Parent:FindFirstChild("Humanoid")
		if Humanoid and not db then
			db = true
			game.Lighting.FogEnd = 20
			task.wait(1)
			db = false
		end
	end)
end)

2 Likes

where I will put these scripts?

Local script(client-side script) in starterplayercharacter or replicatedFirst
Script(server-side)in object
Remoteevent in replicatedstorage

2 Likes

@vojtasuper2
Tel me Does it work?

2 Likes

yea I tried something and now it works.
Thanks!

2 Likes

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