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

How would I make lighting effects go only into local player?

Asked by 2 years ago

This regular script makes lighting effects when touched by humanoid, but I need the lighting effects to only affect local player. How can I do that?

local part = script.Parent

local function onPartTouched(otherPart)
    local partParent = otherPart.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
        game.Lighting.ColorCorrection.TintColor = Color3.new(1, 1, 0)
        game.Lighting.Blur.Size = 7
        game.Lighting.ColorCorrection.Brightness = 0.1
    end
end

part.Touched:Connect(onPartTouched)

1 answer

Log in to vote
4
Answered by
appxritixn 2235 Moderation Voter Community Moderator
2 years ago

Use a RemoteEvent, and handle the client-side lighting effects from the client.

Script (as child of part)

local part = script.Parent
local event = -- location of RemoteEvent

local function onPartTouched(otherPart)
    local partParent = otherPart.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
        event:FireClient(game.Players:GetPlayerFromCharacter(humanoid.Parent))
    end
end

part.Touched:Connect(onPartTouched)

LocalScript

local event = -- location of the same RemoteEvent
local function onPartTouched()
    game.Lighting.ColorCorrection.TintColor = Color3.new(1, 1, 0)
    game.Lighting.Blur.Size = 7
    game.Lighting.ColorCorrection.Brightness = 0.1
end

event.OnClientEvent:Connect(onPartTouched)
0
o wow that works thanks Jakob_Cashy 79 — 2y
Ad

Answer this question