Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Touch function problems including colours Any possible fix? [SOLVED]

Asked by 5 years ago
Edited 5 years ago

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

1
Region3 might be what you're looking for Filipalla 504 — 5y
0
How do you even use Region3 User#16405 0 — 5y
1
have you tried brickcolor if the thing is a part? ScrubSadmir 200 — 5y
0
already fixed, the RGB values were messed up User#16405 0 — 5y

Answer this question