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

Console is returning strange errors from my Server Script?

Asked by 6 years ago
Edited 6 years ago

Hello again, I'm quite new to remote events and such, but for some reason I keep getting this error each time I go into play mode:

19:36:19.000 - Maximum event re-entrancy depth exceeded for RemoteEvent.OnClientEvent 19:36:19.000 - While entering function defined in script 'ServerScriptService.GameScript', line 30 19:36:19.001 - Players.PyccknnXakep.PlayerGui.Game.gameScript:12: bad argument #3 to 'Text' (string expected, got nil) 19:36:19.002 - Stack Begin

Here is (part of) the server script:

    local ui1 = game.ReplicatedStorage.ui1
ui1.OnClientEvent:connect(function(player)
    ui1:FireAllClients("Game Over")
end)
local ui2 = game.ReplicatedStorage.ui2
ui2.OnClientEvent:connect(function(player)
    ui2:FireAllClients("Intermission")
end)
local ui3 = game.ReplicatedStorage.ui3
ui3.OnClientEvent:Connect(function(player)
    ui3:FireAllClients("Get Ready...")
end)
local ui4 = game.ReplicatedStorage.ui4
ui4.OnClientEvent:Connect(function(player)
    ui4:FireAllClients("Choosing Map...")
end)
----------
while true do
ui1:FireAllClients()
--...
ui2:FireAllClients()
--...
ui3:FireAllClients()
--...
ui4:FireAllClients()
end
----------

And here is the local script in the StarterGui that changes the text:

local ui1 = game.ReplicatedStorage.ui1
ui1.OnClientEvent:connect(function(text1)
    main.time_left.Text = text1
end)
local ui2 = game.ReplicatedStorage.ui2
ui2.OnClientEvent:connect(function(text2)
    main.time_left.time_header.Text = text2
end)
local ui3 = game.ReplicatedStorage.ui3
ui3.OnClientEvent:connect(function(text3)
    main.time_left.time_header.Text = text3
end)
local ui4 = game.ReplicatedStorage.ui4
ui4.OnClientEvent:connect(function(text4)
    main.time_left.time_header.Text = text4
end)

--... Means that it's continuing on with the script, like I said that's part of the script. I can't quite figure out why I'm getting an error. Any help appreciated though.

2 answers

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

There's no wait on the while statement. You can use one RemoteEvent for this. You can't use OnClientEvent in a ServerScript, that's for the Local part. Another way to do this is to have the client track a value in ReplicatedStorage changed by a Server Script that displays Text based on the Changed event in a LocalScript.

ServerScript

local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Name = 'display_text'
RemoteEvent.Parent = game:GetService("ReplicatedStorage")


local readyplayer1 = {
    'Get ready';
    'Get set';
    'Get crunk';
    'Goooo!'
}

for i,v in pairs(readyplayer1) do 
    RemoteEvent:FireAllClients(v)
    wait(1)
end

LocalScript

local RemoteEvent =game:GetService("ReplicatedStorage"):WaitForChild("display_text")
RemoteEvent.OnClientEvent:Connect(function(str)
    yourtextlabel.Text = str
end)
0
Like when I fire the RemoteEvent I can fire a String with it? PyccknnXakep 1225 — 6y
0
I'm using OnClientEvent on the Local part by the way. PyccknnXakep 1225 — 6y
0
And I changed it to while wait() do and it's till throwing the error PyccknnXakep 1225 — 6y
0
Thank you, but I need to have them show up at different times. How could I do that? PyccknnXakep 1225 — 6y
View all comments (6 more)
0
Fire it like I did whenever you want from a Server Script. RemoteEvent:FireAllClients('text here') Azarth 3141 — 6y
0
Like I could do RemoteEvent:FireAllClients(readyplayer1[1])? PyccknnXakep 1225 — 6y
0
yup Azarth 3141 — 6y
0
And then later on I could fire RemoteEvent:FireAllClients(readyplayer1[2])? PyccknnXakep 1225 — 6y
0
yes Azarth 3141 — 6y
0
Okay, thank you so much! PyccknnXakep 1225 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

The first error is because you are firing too many events at once. I think one reason may be because you forgot to put a wait() in your while loop, server script line 18. The second error about the text is apparently you are passing nil instead of a string.

0
rip i just noticed someone answered right when i was typing this Operation_Meme 890 — 6y
0
Yeah but I'm not firing them at once, theres a delay between them so they fire at different times. PyccknnXakep 1225 — 6y
0
oh.. sorry, looking at your script it seemed like that. Operation_Meme 890 — 6y

Answer this question