Ok so I have a part and when it is touched by any object, it will look for a PointLight then disable it. However it does not work. I used tweening to move the part, but I am not sure if that is the case.
script.Parent.Touched:Connect(function(light)
if light.Name == "Light" then
local point = light:FindFirstChild("PointLight")
if point then
point.Enabled = false
end
end
end)
Try printing around the script to see if it’s running. It might be because of tween service, I think it doesn’t activate .Touched events (not sure about this).
Try this:
script.Parent.Touched:Connect(function(hit)
local point = light:FindFirstChild("PointLight")
if point then
point.Enabled = false
end
end)
The argument in the Touched event is the individual part which is touching the part. For example, it could be a player’s left foot. You should probably check if the light exists inside the parent of the part touching (if it is a model/has multi-parts), as well as the individual part that is.
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("PointLight") then
hit.PointLight.Enabled = false
elseif hit.Parent:FindFirstChild("PointLight") then
hit.Parent.PointLight.Enabled = false
end
end)