Normal Script the one that fires the remote event
01 | local TimerStart = Instance.new( "RemoteEvent" ) |
02 | TimerStart.Parent = game.ReplicatedStorage |
03 | TimerStart.Name = "TimerStart" |
04 |
05 | function onTouch() |
06 | print ( "working" ) |
07 | TimerStart:FireClient() |
08 | end |
09 |
10 |
11 | script.Parent.Touched:connect(onTouch) |
local script the one that runs the timer
01 | local time = 0 |
02 | local function TimerStart() |
03 | print ( "working2" ) |
04 | script.Parent.Parent.TextLabel.Text = 0 |
05 | for i = 1 , 9999 do |
06 | wait( 0.1 ) |
07 | time = time + 0.1 |
08 | script.Parent.Parent.TextLabel.Text = tostring (time) |
09 |
10 |
11 | end |
12 | end |
Heres the new updated local script
01 | local time = 0 |
02 | local function TimerStart() |
03 | print ( "working2" ) |
04 | script.Parent.Parent.TextLabel.Text = 0 |
05 | for i = 1 , 9999 do |
06 | wait( 0.1 ) |
07 | time = time + 0.1 |
08 | script.Parent.Parent.TextLabel.Text = tostring (time) |
09 |
10 | TimerStart.OnClientEvent:Connect(TimerStart) |
11 |
12 | end |
13 | end |
Looks like you're missing an OnClientEvent
in your Local Script. Should also rename your event so it's not the same as your function.
Local Script
1 | TimerStart.OnClientEvent:Connect(TimerStart) |
Also, specify which client to start the timer. Server Script
1 | TimerStart:FireClient(player) |
Here is what you should have:
Local Script
01 | local event = game:GetService( "ReplicatedStorage" ):WaitForChild( "TimerStart" ) |
02 | local time = 0 |
03 |
04 | local function TimerStart() |
05 | print ( "working2" ) |
06 | script.Parent.Parent.TextLabel.Text = 0 |
07 |
08 | for i = 1 , 9999 do |
09 | wait( 0.1 ) |
10 | time = time + 0.1 |
11 | script.Parent.Parent.TextLabel.Text = tostring (time) |
12 | end |
13 | end |
14 |
15 | event.OnClientEvent:Connect(TimerStart) |
Server Script
01 | local TimerStart = Instance.new( "RemoteEvent" ) |
02 | TimerStart.Parent = game.ReplicatedStorage |
03 | TimerStart.Name = "TimerStart" |
04 |
05 | function onTouch(hit) |
06 | print ( "working" ) |
07 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 | if player then |
09 | TimerStart:FireClient(player) |
10 | end |
11 | end |
12 |
13 | script.Parent.Touched:Connect(onTouch) |