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

How to do if I touch a trigger, the fog changes only for Local Player?

I created a script in a part and I scripted this:

triggername="FogTrigger2"

function onTouched(part)
	if part.Parent ~= nil then
	local h = part.Parent:findFirstChild("Humanoid")
		if h~=nil then
			local teleportfrom=script.Parent.Enabled.Value
			if teleportfrom~=0 then
				local lightning = game.Lighting
				lightning.FogColor = Color3.fromRGB(193, 184, 115)
				lightning.FogEnd = 100
			else
				print("Could not find the trigger")
			end
		end
	end
end

script.Parent.Touched:connect(onTouched)

Now how to do it works only for Local Player? I enabled Filtered Enabled and isn't working. Thanks.

1 comment

0

Use a RemoteEvent that tells the client to change the lighting. The local script would do the property changes.

2 answers

You can use a remote event. Or even a local script.

It's easier to use a LocalScript. Simply put it somewhere that it will execute and copy that exact code. Just change the last line:

local Part = game.Workspace.Part -- CHANGE THIS
Part.Touched:connect(function(part)
	if part.Parent.Name == game.Players.LocalPlayer.Name then
		onTouched(part)
	end
end)

Haven't test code. Let me know if there's errors.

1 comment

0

i tested mine>:)

  1. you did not define "part"
  2. i'm pretty sure this is how you do the event "Touched"
local part = game.Workspace.INSERT PART NAME HERE
part.Touched:Connect(function()
	
end)

you can clone your smoke each time, and replace the function with my code.

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