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:

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.

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:

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.

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"
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.

Answer this question