So, I am making a till (this information is not necessary) and it has a status light, which shows green if there is a worker standing there and then red if nobody is there. However it seems to be firing the touch and touchended functions even when a player is standing still there. (I am using R15 Character Models)

Here is the code below

-- Till
-- by nathdabomb

local det = script.Parent.plrDet -- The Part For Detecting the player
local config = script.Parent.Configuration -- not needed yet
local l = script.Parent.SatLight.light.st -- The Status Light (Green(Active) Red(Inactive))

local debounce = false -- just.. debounce

det.Touched:connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		if debounce == false then
			print("Till ACTIVE") 
			l.Color = Color3.fromRGB(39, 174, 96)  -- Supposed to show green.. shows blue
			debounce = true
			-- Till Active
		end
	end
end)

det.TouchEnded:connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		if debounce == true then
			print("Till INACTIVE")
			l.Color = Color3.fromRGB(231, 76, 60) -- Supposed to show green.. shows beige 
			debounce = false
			-- Till Inactive
		end
	end
end)

The colours are also messed up i have tried the code with Color3.New and Color3.fromRGB any help would be greatly appreciated

4 comments

1

Region3 might be what you're looking for

0

How do you even use Region3

1

have you tried brickcolor if the thing is a part?

0

already fixed, the RGB values were messed up