Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

01triggername="FogTrigger2"
02 
03function onTouched(part)
04    if part.Parent ~= nil then
05    local h = part.Parent:findFirstChild("Humanoid")
06        if h~=nil then
07            local teleportfrom=script.Parent.Enabled.Value
08            if teleportfrom~=0 then
09                local lightning = game.Lighting
10                lightning.FogColor = Color3.fromRGB(193, 184, 115)
11                lightning.FogEnd = 100
12            else
13                print("Could not find the trigger")
14            end
15        end
16    end
17end
18 
19script.Parent.Touched:connect(onTouched)

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

0
Use a RemoteEvent that tells the client to change the lighting. The local script would do the property changes. xPolarium 1388 — 6y

2 answers

Log in to vote
0
Answered by
oftenz 367 Moderation Voter
6 years ago
Edited 6 years ago

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:

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

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

0
i tested mine>:) natonator63 29 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
  1. you did not define "part"
  2. i'm pretty sure this is how you do the event "Touched"
1local part = game.Workspace.INSERT PART NAME HERE
2part.Touched:Connect(function()
3 
4end)

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

Answer this question