So i was trying to make an obby where when you hit the start part the timer would pop up on your screen and start counting up. Once you reached the end part, it would tp you back to the main area. Instead what happens is when you hit the start part the timer doesnt show up on your screen and the tp doesnt work.
Here is the obby timer code:
local start = game.Workspace.ObbyStart
local stop = game.Workspace.ObbyEnd
local timerPart = game.StarterGui.ObbyTimer
local timerText = game.StarterGui.ObbyTimer.TextLabel
local timerDuration = 0
local timerActive = false
local ObbyMechanics = game.Workspace.ObbyStart.ObbyMechanics
local Completed = game.Workspace.ObbyStart.ObbyMechanics:GetAttribute(âCompletedâ)
local count = 0
timerPart.Enabled = false
local ligma = false
local function startTimer()
print(âTimer startedâ)
timerActive = true
timerPart.Enabled = true
timerText.Enabled = true
while Completed == false do
count += 1
timerText.Text = count
wait(1)
end
end
if ligma == true then
local function obbyDone(stopTimer)
local character = stopTimer.Parent
local humanoid = character:FindFirstChildWhichIsA(âHumanoidâ)
print(âattempting to tpâ)
if humanoid and timerActive == true then
print("made it to get attribute")
ObbyMechanics:GetAttribute('Completed')
ObbyMechanics:SetAttribute('Completed', true)
timerText.Text = "Final score: "..timerDuration
wait(2)
timerActive = false
timerPart.Enabled = false
ObbyMechanics:SetAttribute('Completed', false)
end
end
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
local function stopPressed(partTouched)
local character = partTouched.Parent
local humanoid = character:FindFirstChildWhichIsA(âHumanoidâ)
print(âend touchedâ)
if humanoid and timerActive == true then
print("ending timer")
ligma = true
end
end
start.Touched:Connect(buttonPressed)
stop.Touched:Connect(stopPressed)
And this is the tp code:
local TeleportPart1 = script.Parent.TeleportPart1
local TeleportPart2 = script.Parent.TeleportPart2
local Completed = game.Workspace.ObbyStart.ObbyMechanics:GetAttribute(âCompletedâ)
if Completed == true then
TeleportPart1.Touched:Connect(function(hit)
local w = hit.Parent:FindFirstChild(âHumanoidRootPartâ)
print(âabout to tpâ)
if w then
w.CFrame = TeleportPart2.CFrame + Vector3.new(0, 5, 0)
TeleportPart2.CanTouch = false
wait(1)
TeleportPart2.CanTouch = true
print(âtp doneâ)
end
end)
end
Any help is appreciated! Thank you for your time.