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

why is my local script not running locally?

Asked by 4 years ago
01local start = game.Workspace:FindFirstChild("Start")
02local endPart = game.Workspace:FindFirstChild("End")
03local textlabel = script.Parent
04local finished = script.Parent.finished
05 
06local function timer()
07    for t = 0,math.huge,0.05 do
08        wait(0.0499999999)
09        if finished.Value == true then break end
10        local stringT = tostring(t)
11        if #(tostring(t)) == 3 then
12            t = t.."0"
13        elseif #(tostring(t)) == 1 then
14            t = t..".00"
15        end
View all 31 lines...

the code on top is for a timer. the timer starts when the players touches the "start" part and ends when player touches the "end" part

this is in a local script but for some reason the timer runs for every players, meaning globally. im confused, why is this running globally and not locally even though its a local script

local script is in StarterGui>ScreenGui>TextLabel>Localscript

any help is greatly appreciated!

1 answer

Log in to vote
1
Answered by
sayer80 457 Moderation Voter
4 years ago
Edited 4 years ago

You have to check if the player who touched the part is the localplayer!!!

01local start = game.Workspace:FindFirstChild("Start")
02local endPart = game.Workspace:FindFirstChild("End")
03local textlabel = script.Parent
04local finished = script.Parent.finished
05 
06local function timer()
07    for t = 0,math.huge,0.05 do
08        wait(0.0499999999)
09        if finished.Value == true then break end
10        local stringT = tostring(t)
11        if #(tostring(t)) == 3 then
12            t = t.."0"
13        elseif #(tostring(t)) == 1 then
14            t = t..".00"
15        end
View all 36 lines...
Ad

Answer this question