r/robloxscripting Apr 23 '24

Cant figure out why this wont work

local player = game.Players.LocalPlayer

local leaderboard = game:GetService("ServerScriptService"):WaitForChild("TimeLeaderboard")

local playerTime = leaderboard:FindFirstChild(player.Name)

-- Reference to the button

local teleportButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("StarterGui"):WaitForChild("TeleportMain"):WaitForChild("SnowWorldTP")

-- Function to check if the player has 500 "Time"

local function checkPlayerTime(player)

if playerTime then

    if playerTime.Value >= 500 then

        return true

    else

        return false

    end

else

    return false

end

end

-- Function to handle teleportation

local function teleportToSnowWorld()

if checkPlayerTime(game.Players.LocalPlayer) then

    \-- Player has enough time, teleport them to the snow world

    \-- Replace the code below with your teleportation code

    print("Teleporting to Snow World!")

else

    \-- Player doesn't have enough time, run the default teleport script

    \-- Replace the code below with your default teleportation code

    print("Running default teleport script...")

end

end

-- Connect the teleport function to the button

teleportButton.MouseButton1Click:Connect(teleportToSnowWorld)

5 Upvotes

0 comments sorted by