What do you want to achieve?
Incredibly simple. I just want to detect when a part changes color and have a point light connected to it change color as well.
2/3. What is the issue?
None of the scripts I tried worked.
I mainly tried using .Changed. I do think that’s the way to go about this, but I’m just not sure exactly what I need.
This is the code I used to change the color of the part if it helps.
local IsActive = false
local function Change(Hit)
if Hit.Parent:IsA("Model") and Hit.Parent:FindFirstChildWhichIsA("Humanoid") and IsActive == false then
IsActive = true
CPart.BrickColor = BrickColor.new ("Lime green")
wait(2)
CPart.BrickColor = BrickColor.new ("Really red")
IsActive = false
end
end
CPart.Touched:Connect(Change)
Why can’t you just turn on or off the light while changing the part color?
Something like this:
local IsActive = false
local function Change(Hit)
if Hit.Parent:IsA("Model") and Hit.Parent:FindFirstChildWhichIsA("Humanoid") and IsActive == false then
IsActive = true
CPart.BrickColor = BrickColor.new ("Lime green")
Light.Enabled = true
wait(2)
Light.Enabled = false
CPart.BrickColor = BrickColor.new ("Really red")
IsActive = false
end
end
CPart.Touched:Connect(Change)
local LineOfSight = 100
local RS = game:GetService("RunService")
RS.Heartbeat:Connect(function()
local rayparams = RaycastParams.new()
rayparams.FilterDescendantsInstances = {script.Parent}
local ray = workspace:Raycast(script.Parent.Position, script.Parent.CFrame.LookVector * LineOfSight, rayparams)
if ray then
if ray.Instance.Name == "ColorChangingPart" then --or whatever your part is called
script.Parent.Color = ray.Instance.Color
end
end
end)