I want to want to make a timer bridge
when i run the code it is not working idk why?
local bridge = script.Parent
-- Gets the button as it's typed in the Explorer
local button = game.Workspace.ButtonBridge
-- Gets the part for the display
local timerPart = game.Workspace.TimerDisplay
-- Gets the Text that will display the timer
local timerText = timerPart.SurfaceGui.TextLabel
-- How long players have to cross the bridge
local timerDuration = 5
local timerStarted= false
local function startTimer()
print("Countdown started")
timerActive = true
bridge.Transparency = 0
bridge.CanCollide = true
-- For loop that counts down from timerDuration
for count = timerDuration, 0, -1 do
timerText.Text = count
wait(1)
end
-- Make the bridge not walkable
bridge.Transparency = 0.8
bridge.CanCollide = false
timerText.Text = ""
timerActive = false
end
local function buttonPressed (partTouched)
local character = partTouched.Parent
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
print("part touched")
if humanoid and timerActive == false then
print("starting timer")
startTimer()
end
end
button.Touched:Connect(buttonPressed)