There's a few reasons why your script might not work. The first potential reason is the second line of your script:
local StadSwitchEvent = ReplicatedStorage:WaitForChild("StadSwitch")
Calling the WaitForChild method without the second argument can result in an infinite yield which is when the script is paused forever. If you manually created the RemoteEvent under ReplicatedStorage, then this shouldn't be a problem. However, if you created the RemoteEvent using a server script, you need to make sure that the RemoteEvent is actually being created with the correct parent (ReplicatedStorage in this case) and the correct name (StadSwitch in this case).
The second potential issue is the third line of the script:
local DeleteStadAndAdd = workspace.StadiumSelect
Unless you're confident that this instance is always part of the workspace and isn't replaced at any time, you might want to use FindFirstChild to prevent errors. If you do this, make sure you check if the value of the variable is nil so you can prevent errors later on in the script.
I've looked at your script and chances are that your code works fine which leads me into the third potential issue. You're probably just calling the RemoteEvent incorrectly from the server. To trigger the OnClientEvent event for a specific player, use the FireClient method on the server:
StadSwitchEvent:FireClient(game.Players["NAME"])
If you want to trigger the event for every player in the game at the same time, you can use the FireAllClients event:
StadSwitchEvent:FireAllClients()
Because your RemoteEvent doesn't accept any arguments, none were provided in the examples above, but if your RemoteEvent accepts arguments, then you just pass them after the player argument for FireClient or just pass them directly for FireAllClients.
I hope this helps you find the solution to your scripting issue :)
2 comments
Any errors? Is the print statement working?
if the print works then there's probably something wrong with your loop, try using ipairs instead.