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

how to fix this display timer in a localscript? [closed]

Asked by
hokyboy 270 Moderation Voter
4 years ago
local Timer = script.Parent.Timer
local time = 0
local Button = script.Parent.Button

Button.MouseButton1Click:Connect(function()
    while true do
        wait(1)
    time = time + 1
 print(time)
end
end)

Timer.Text = time
time.Changed:Connect(function()
    Timer.Text = time
end)

Closed as Non-Descriptive by MachoPiggies and User#5423

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 4 years ago

You're overcomplicating it:

local Timer = script.Parent.Timer
local time = 0
local Button = script.Parent.Button

Button.MouseButton1Click:Connect(function()
    while true do
        wait(1)
        time = time + 1
        Timer.Text = tostring(time) --// You don't have to put the tostring there, it's just a precaution
   end
end)

Timer.Text = time
Ad
Log in to vote
0
Answered by
4TH4RV 20
4 years ago
Edited 4 years ago
local Timer = script.Parent.Timer
local time = 0
local Button = script.Parent.Button

Button.MouseButton1Click:Connect(function()
    while wait(1) do
        time = time + 1
    Timer.Text = time
   end
end)