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

Why doesn't this server/client remoteevent function fire?

Asked by 5 years ago
Edited 5 years ago

Okay, Working on Server/Client events. Others fire just fine, this one is not. Any insights? They are called directly for debugging.

Edit: The server scripts are cloned from ReplicatedStorage to instanced parts and the localscript is a child of a StarterGui object

Clone(d) from ReplicatedStorage and parented to a StartPart.Touched event

    -- start part on touched, Clone(d) from ReplicatedStorage and parented to a Part Touch event
    local startTime = os.time()
    game.ReplicatedStorage.StartTimer:FireClient(player, startTime)

Clone(d) from ReplicatedStorage and parented to a GoalPart.Touched event

    -- Goal part touched, Clone(d) from ReplicatedStorage and parented to a Part Touch 
    local stopTime = os.time()
    game.ReplicatedStorage.StopTimer:FireClient(player, stopTime)   

Client LocalScript to update GUI with timer


local function StartClock(_startTime) print ("This fired") -- Never prints because this function is never actually called. parent.Active.Value = true team = player.Team.Name startTime = _startTime -- or os.time() end local function StopClock(_endTime) parent.Active.Value = false runningTime = _endTime - startTime end game.ReplicatedStorage.StartTimer.OnClientEvent:Connect(StartClock) game.ReplicatedStorage.StopTimer.OnClientEvent:Connect(StopClock)

I'm at a loss on why these won't fire.. using the Print to debug. Also the BoolValue attached to the ScreenGui item is never changed to true or false, another way I can tell they aren't fired.

Edit: There is no output or error feedback. The parent.Active.Value is a BoolValue that isn't changed in the fire events either which indicates to me that it isn't actually firing. However, another line not shown fires another server event in the StartPart.Touched event that opens a Gui dialog similar the the deprecated Hint object to wish the player luck as the race starts, so I know some of the server/client events are firing. Just not this one. Could it be where or how the server scripts are cloned()?

2 answers

Log in to vote
0
Answered by 5 years ago

It may be because your :FireClient() for StartTimer is in a different server script. Have you tried moving that line into your main script? It would look something like this:

-- start part touched
game.ReplicatedStorage.StartTimer:FireClient(player, os.time())
-- Goal part touched
game.ReplicatedStorage.StopTimer:FireClient(player, stopTime)   

local function StartClock(_startTime)
    print ("This fired")  -- Never prints
    parent.Active.Value = true
    team = player.Team.Name
    startTime = _startTime -- or os.time()
end

local function StopClock(_endTime)
    parent.Active.Value = false
    runningTime = _endTime - startTime
end

game.ReplicatedStorage.StartTimer.OnClientEvent:Connect(StartClock)
game.ReplicatedStorage.StopTimer.OnClientEvent:Connect(StopClock)

If not, can you show us any error text in the output window, if any?

Ad
Log in to vote
0
Answered by 5 years ago

So I had to walk away for a while and come back, when I did, I realized I had an infinite loop run before the connection was made to the events. Just moved some code around and it works just fine now.

Answer this question