Color does not change in Gui

The two highlighted lines do not change the Frame color. Help me please.

local DeletePart = script.Parent.Parent.Delete
local Green = script.Parent.Parent.Signals.Green
local Red = script.Parent.Parent.Signals.Red
local Signal1 = script.Parent.Parent.Signal1
local Signal2 = script.Parent.Parent.Signal2
local Manual = game.ServerStorage.Values.Manual1
local SignallerMenu = game.StarterGui.SignallerMenu
local GreenSignallerMenu = SignallerMenu.Frame.Signalls.Signall.Green
local RedSignallerMenu = SignallerMenu.Frame.Signalls.Signall.Red

function onTouched(part)
	print("Касание красного маркера (Signal1)")
	if Manual.Value == false then
		print("Не в ручном управлении (Signal1)")
		print(part.Name)
		if part.Name == "SignalPart" then
			print("Красный включен (Signal1)")
			Red.BrickColor = BrickColor.Red()
			Green.BrickColor = BrickColor.new("Black")
			Signal1.Value = BrickColor.new("Really red")
			Signal2.Value = BrickColor.new("Black")
			DeletePart.Script.Enabled = true
--does not change
			GreenSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0, 0)
			RedSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0.886275, 1)
--end of the gods
		end
	end
end

script.Parent.Touched:connect(onTouched)
2 Likes

use

local SignallerMenu = game.Players.Localplayer.SignallerMenu

because its cloned from the starter gui to where I mentioned
(I had this problem to took me hours)

1 Like

local SignallerMenu = game.Players.Localplayer.PlayerGui.SignallerMenu
You forgot to add PlayerGui to it

2 Likes

oh yes thanks (cahr limit[11111111111111])

3 Likes

Actually not Localplayer, but LocalPlayer and use GetService and also WaitForChild to avoid errors :point_up::nerd_face:
Like:

 game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("SignallerMenu")
3 Likes

you don’t need to use getservice

4 Likes

Using GetService is a better pratice.

2 Likes

Actually one guy said me this :point_up: :nerd_face: :

3 Likes

Now it doesn’t work at all :frowning:
Here’s what I did:

local DeletePart = script.Parent.Parent.Delete
local Green = script.Parent.Parent.Signals.Green
local Red = script.Parent.Parent.Signals.Red
local Signal1 = script.Parent.Parent.Signal1
local Signal2 = script.Parent.Parent.Signal2
local Manual = game.ServerStorage.Values.Manual1
local SignallerMenu =  game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("SignallerMenu")
local GreenSignallerMenu = SignallerMenu.Frame.Signalls.Signall.Green
local RedSignallerMenu = SignallerMenu.Frame.Signalls.Signall.Red

function onTouched(part)
	print("Касание красного маркера (Signal1)")
	if Manual.Value == false then
		print("Не в ручном управлении (Signal1)")
		print(part.Name)
		if part.Name == "SignalPart" then
			print("Красный включен (Signal1)")
			Red.BrickColor = BrickColor.Red()
			Green.BrickColor = BrickColor.new("Black")
			Signal1.Value = BrickColor.new("Really red")
			Signal2.Value = BrickColor.new("Black")
			DeletePart.Script.Enabled = true
			GreenSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0, 0)
			RedSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0.886275, 1)
		end
	end
end

script.Parent.Touched:connect(onTouched)
1 Like

Are there any errors?
Edit: Is this a server script or a local script? You can’t access ServerStorage from a local script. If this is a server script, then you also can’t use game:GetService(“Players”).LocalPlayer

If your script is a server script, do this:

local DeletePart = script.Parent.Parent.Delete
local Green = script.Parent.Parent.Signals.Green
local Red = script.Parent.Parent.Signals.Red
local Signal1 = script.Parent.Parent.Signal1
local Signal2 = script.Parent.Parent.Signal2
local Manual = game.ServerStorage.Values.Manual1

function onTouched(part)
	local Humanoid = part.Parent:FindFirstChild("Humanoid")
	if Humanoid then
		local SignallerMenu = game:GetService("Players"):FindFirstChild(Humanoid.Parent.Name).PlayerGui:WaitForChild("SignallerMenu")
		local GreenSignallerMenu = SignallerMenu.Frame.Signalls.Signall.Green
		local RedSignallerMenu = SignallerMenu.Frame.Signalls.Signall.Red
		print("Касание красного маркера (Signal1)")
		if Manual.Value == false then
			print("Не в ручном управлении (Signal1)")
			print(part.Name)
			if part.Name == "SignalPart" then
				print("Красный включен (Signal1)")
				Red.BrickColor = BrickColor.Red()
				Green.BrickColor = BrickColor.new("Black")
				Signal1.Value = BrickColor.new("Really red")
				Signal2.Value = BrickColor.new("Black")
				DeletePart.Script.Enabled = true
				GreenSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0, 0)
				RedSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0.886275, 1)
			end
		end
	end
end
3 Likes

Please excuse me for not noticing your question. I’ll test your script soon. Thank you!

2 Likes

Unfortunately it doesn’t work, there’s nothing in OutPut

1 Like

Is it a server script or local script?

3 Likes

This is a server script. HMHMhmdsfafgdfgddg

1 Like

I forgot to add script.Parent.Touched:Connect(onTouched) to the end of the script. Add that back if you haven’t already.

2 Likes

I added it, but it still doesn’t work :frowning:

1 Like

You have to be a bit more clear than it just doesn’t work. We need errors or you need to put print statements into your code block so we can trace the problem.

If this doesn’t work for you, then the problem is not with the code, but with where the script is, or a missing asset or some other logic problem.

local PlayerServ = game:GetService("Players")
local ServerStor = game:GetService("ServerStorage")

local DeletePart = script.Parent.Parent.Delete
local Green = script.Parent.Parent.Signals.Green
local Red = script.Parent.Parent.Signals.Red
local Signal1 = script.Parent.Parent.Signal1
local Signal2 = script.Parent.Parent.Signal2
local Manual = ServerStor.Values.Manual1 --game.ServerStorage.Values.Manual1


function onTouched(part)
	local humanoid = part.Parent:FindFirstChild("Humanoid")
	if(not(humanoid))then return end --Did not find humanoid
	
	local player = PlayerServ:GetPlayerFromCharacter(humanoid.Parent)
	if(not(player))then return end --No player associated with char
	
	local signallerMenu = player.PlayerGui:FindFirstChild("SignallerMenu")
	if(not(signallerMenu))then return end --Couldn't find it
	
	--local SignallerMenu = player.PlayerGui:WaitForChild("SignallerMenu") --THIS CAN HANG, WAITING, CAUSE TIMEOUT
	local GreenSignallerMenu = signallerMenu.Frame.Signalls.Signall.Green
	local RedSignallerMenu = signallerMenu.Frame.Signalls.Signall.Red
	print("Касание красного маркера (Signal1)")
	
	if(Manual.Value)then return end --Value was true
	
	print("Не в ручном управлении (Signal1)")
	print(part.Name)
	
	if(part.Name ~= "SignalPart")then return end --Part was not named "SignalPart"

	print("Красный включен (Signal1)")
	Red.BrickColor = BrickColor.Red()
	Green.BrickColor = BrickColor.new("Black")
	Signal1.Value = BrickColor.new("Really red")
	Signal2.Value = BrickColor.new("Black")
	DeletePart.Script.Enabled = true
	GreenSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0, 0)
	RedSignallerMenu.BackgroundColor3 = Color3.fromHSV(0, 0.886275, 1)
end

script.Parent.Touched:Connect(onTouched)
1 Like