#touch event don't working

1 messages · Page 1 of 1 (latest)

dapper rock
#

if i put print("work") in this touch event this is don't printing, but start text (unlocked...) changes
so script see lock part and change text label, but this function don't working

#

local Module = {}

local function SwitchCollision(Boolean, Barriers: Folder)
for i, v in Barriers:GetChildren() do
if v.Name == "RealBarrier" then
v.CanCollide = Boolean
else
v.CanCollide = Boolean
v.Transoarency = (Boolean == true) and 0.5 or 1
end
end
end

function Module.SetupLocker(Plot: Model, LockerPart: Part, Barriers: Folder)
local Billboard = LockerPart.BillboardGui
local Status: TextLabel = Billboard.Status
local Timer: TextLabel = Billboard.Seconds

Billboard.Enabled = true

Status.Text = "UNLOCKED"
Timer.Text = ""

Status.Changed:Connect(function()
    if Status.Text == "UNLOCKED" then
        SwitchCollision(false)
    else
        SwitchCollision(true)
    end
    
Status.Text = "UNLOCKED"
Timer.Text = ""

LockerPart.Touched:Connect(function(hit)
    if hit.Parent.Name ~= Plot.Name then return end
    
    if Status.Text == "UNLOCKED" then
        Plot:SetAttribute("Locked", true)
        Status.Text = "Locked"
        
        spawn(function()
            for i = 60, 1, -1 do
                Timer.Text = i
                task.wait(1)
            end
            
        Plot:SetAttribute("Locked", false)
        Status.Text = "UNLOCKED"
        Timer.Text = ""
        
        end)
    end
end)

end)

end

return Module

molten python
#

@dapper rock v.Transoarency

#

first mistake

dapper rock
#

i already change that

#

thx

#

but touch event not working

molten python
dapper rock
#

oh, im forgot, im change that to SwitchCollision(true, Barriers)

#

collision is working

molten python
dapper rock
#

im change that

#

output dont have any errors

#

all works perfectly and script see lock part and change text

molten python
dapper rock
#

in touch event?

molten python
#

I would help find the error myself right now, but I just quickly looked at the script because I'm busy

dapper rock
#

ok, im go to game and try status change function, im change text to locked in properties, but barriers dont switch collision and dont print work text, mb mistake in this part of code?

frosty basinBOT
#

studio** You are now Level 1! **studio

dapper rock
#

ohhh yeeah

#

im forgot end) after function and write end) after all script

#

thanks for help

molten python
molten python