Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I was wondering why my timer script is not working?

Asked by 3 years ago

Hi, I have tried making my own script for a military game of mine. I have failed, again. Basically what i want it to do is when you touch a part, a timer starts and the time is stated on a surface gui at the end of the obstacle course, when you touch the end brick, you end the timer. Instead what it is doing is crashing my roblox studio. I tested it out in a normal roblox game, and it did nothing. Please help, if you can i would really appreciate it!

scripts:

local part = script.Parent

part.Touched:Connect(function(hit)
    game.Workspace.Time1.SurfaceGui.TextLabel.Text = "Time: "..Time.Value
end)

local StartPart = script.Parent
local EndPart = game.Workspace.EndTimePart


EndPart.Touched:Connect(function(hit)
    script.Disabled = true
end)


StartPart.Touched:Connect(function(hit)
    script.Disabled = false
end)

while true do
    StartPart.Touched:Connect(function(hit)
        player.leaderstats.Time.Value = player.leaderstats.Time.Value +1
        wait(1)
    end)
end

leaderstats script:

local Players = game:GetService("Players")

local function leaderboardSetup(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local cash = Instance.new("IntValue")
    cash.Name = "Time"
    cash.Value = 0
    cash.Parent = leaderstats
end

Players.PlayerAdded:Connect(leaderboardSetup)
0
please anyone check my question topo8986 0 — 3y

Answer this question