You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to make the part when you touch it only you will have fog 20
What is the issue?
I don’t know how to make the fog only for you
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)
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.
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.
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)