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

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

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

✓ Accepted answer

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)

1 comment

0

o wow that works thanks

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