#red squiggle i cant figure out

1 messages · Page 1 of 1 (latest)

swift dust
#

the script is meant to have a timer for when the player enters a bound and upon it completing will trigger a teleport event (RM) but the "BetterFunctionName" connection refuses to work properly and i cant figure out why. (i know my code is bad dont ask man)

Code:

local ActiveVal = script.Parent.TimerOn
local TimerDurr = script.Parent.TimerDurr
local part = script.parent
local TeleportService = game:GetService('TeleportService')
local placeId = 73188488770516
local canTeleport = true
local ListofOverlapped = workspace:GetPartsInPart(part)
local RM = game.ReplicatedStorage.TeleportEvent

local function TeleportPlayers(otherPart)
local players = game.Players :FindFirstChild(otherPart.Parent.Name)
if players then
RM.FireServer(players)
print("teleporting..")
script.Parent.BillboardGui.TextLabel.Text = tostring(" Teleporting.")
wait(0.3)
script.Parent.BillboardGui.TextLabel.Text = tostring(" Teleporting..")
wait(0.3)
script.Parent.BillboardGui.TextLabel.Text = tostring(" Teleporting...")
wait(0.3)
end

local function BetterFunctionName(Value)
if ActiveVal.Value == true then

    while TimerDurr.Value >= 0 do
        task.wait(1)
        TimerDurr.Value -= 1
        script.Parent.BillboardGui.TextLabel.Text = tostring(TimerDurr.Value)
        
        if ActiveVal.Value ~= true then
            break
        end
    end
    
    
    while TimerDurr.Value <= 0 do
        print("Sweet jesus")
        TeleportPlayers()
        task.wait(2)
    end
    
    
    
else
    TimerDurr.Value = 30
    script.Parent.BillboardGui.TextLabel.Text = tostring(TimerDurr.Value)
end

end

ActiveVal.Changed:Connect(BetterFunctionName)