What errors print in the terminal?
What actually happens when a humanoid passes through?
By the way, if you want more reliable checks for humanoids, I recommend checking out the ZonePlus module (which uses the SpatialQuery API, which is much less buggy and iffy compared to the Touched event.)
local part = script.Parent
local humanoid
part.Touched:Connect(function(other)
humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
--// Your code goes here (image colors?)
end
end)
if humanoid then
humanoid.Died:Connect(function()
part.Touched:Disconnect()
end)
end
In the code xvywop posted, it would look like this part
if other.Parent ~= nil then
humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
--// Your code goes here (image colors?)
end
end
local part = script.Parent
local humanoid
local Sensor1 = script.Parent
local Signal1 = script.Parent.Parent
part.Touched:Connect(function(other)
if other.Parent ~= nil then
humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
script.Parent.Touched:Connect(function()
script.Parent.Parent.Part.SurfaceGui.TopLabel.Color3 = ("15, 15, 15")
script.Parent.Parent.Part.SurfaceGui.BottomLabel.Color3 = ("255, 0, 0")
end
end)
if humanoid then
humanoid.Died:Connect(function()
part.Touched:Disconnect()
end)
end
This will fix the syntax errors, just missing some “ends” that’s all.
local part = script.Parent
local humanoid
local Sensor1 = script.Parent
local Signal1 = script.Parent.Parent
part.Touched:Connect(function(other)
if other.Parent ~= nil then
humanoid = other.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
script.Parent.Touched:Connect(function()
script.Parent.Parent.Part.SurfaceGui.TopLabel.Color3 = ("15, 15, 15")
script.Parent.Parent.Part.SurfaceGui.BottomLabel.Color3 = ("255, 0, 0")
end)
end
end
end)
if humanoid then
humanoid.Died:Connect(function()
part.Touched:Disconnect()
end)
end
I figured this would generate that error, but I didn’t say anything since this is your script you are working on.
My guess is, after a “humanoid” fires the touch event, you need only find the signal light and change the colors, you don’t need to connect another touch even for that to happen. You would build a “list” of all your signal lights and then “loop” through them and change the colors.
So somewhere in here:
if humanoid then
-- Change Signal Lights
end
Is where you would do that. Right now it looks like you are manually trying to path your way to the signal object. That works fine for one when testing, but it looks like you want to change multiple lights, so using search and loop will do that much faster and easier.