Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Console is returning strange errors from my Server Script?

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

✓ Accepted answer

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)

10 comments

0

Like when I fire the RemoteEvent I can fire a String with it?

0

I'm using OnClientEvent on the Local part by the way.

0

And I changed it to while wait() do and it's till throwing the error

0

Thank you, but I need to have them show up at different times. How could I do that?

0

Fire it like I did whenever you want from a Server Script. RemoteEvent:FireAllClients('text here')

0

Like I could do RemoteEvent:FireAllClients(readyplayer1[1])?

0

yup

0

And then later on I could fire RemoteEvent:FireAllClients(readyplayer1[2])?

0

yes

0

Okay, thank you so much!

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.

3 comments

0

rip i just noticed someone answered right when i was typing this

0

Yeah but I'm not firing them at once, theres a delay between them so they fire at different times.

0

oh.. sorry, looking at your script it seemed like that.

This discussion is preserved as it was. New answers, comments, and votes are closed.