Changing Signals Color

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When your humanoid touches the part, the signal image colour updates.

  2. What is the issue? Include screenshots / videos if possible!
    It’s not working and I have received errors.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I asked a couple people but they didn’t know.

local Sensor1 = script.Parent
local Signal = script.Parent.Parent

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")

Capture3
The Workspace (with the script inside Sensor1)


The error I have received.

Capture4
The signal and the sensor. When you touch the sensor, the signal should have the bottom LED go to red, and the top go to grey.

1 Like

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.)

1 Like

How about taking a look at how an ImageLabel’s properties work.
https://create.roblox.com/docs/reference/engine/classes/ImageLabel

Good spot, didn’t notice you tried to call Color3 on an ImageLabel.
You need to use ImageColor instead.


Tried image colour and received this error. When a player touches it, the top signal goes grey, the bottom goes red.

That’s because its checking if you touched a Script instance, not the actual green zone thing.

How would I make it so when the humanoid touches it, it changes then?

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

That will error out if anything “but” a player touches it. You would have to add:

if other.Parent ~= nil then
-- Do the other code stuff
end

Where would i have to put this?

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

Expected ‘end’ (to close ‘then’ at line 9), got ; did you forget to close ‘function’ at line 16?

Do you know why this is happening at lines 17 to 19

What is the whole script for context?

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. :smile:

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

Hey. got another error, I’m guessing it’s ‘Script.Parent.Touched’ but what do we change that too?

I figured this would generate that error, but I didn’t say anything since this is your script you are working on. :wink:

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.