I decided to try remote events with my spawning script. However, they are not working as I'm new to remote events. The event does fire, the server script isn't picking it up though.
Server Script (in ReplicatedStorage):
train = game.ReplicatedStorage.C70Freight Camera = workspace.CurrentCamera DriveFrame = GUI.Screen.DriveFrame Spawning = GUI.Screen.Spawning script.Parent.Parent.Events.C70Spawn.OnServerEvent:connect(function(player) GUI = player.PlayerGui.MainMenuGui DriveFrame.Visible = false Spawning.Visible = true Spawning.Text = "Spawning..." wait(0.01) local clone = train:Clone() clone.Parent = workspace clone:MakeJoints() wait(1) player.Character.HumanoidRootPart.CFrame = CFrame.new(610.265, 6.551, -3143.202) Spawning.Visible = false player.CameraMode = "Classic" Camera.CameraType = "Custom" Camera.FieldOfView = 80 wait(1) GUI.Screen.IntroMusic:Stop() end)
LocalScript (in Gui)
Frame = script.Parent.Parent C70 = Frame:WaitForChild("Set1") Player = game.Players.LocalPlayer function C70Clicked() if workspace:IsRegion3Empty(Region3.new(Vector3.new(467.505, 6.548, -3076.283), Vector3.new(1152.544, 6.559, -3298.865))) then game.ReplicatedStorage.Events.C70Spawn:FireServer() else script.Parent.Text = "Spawn Occupied! Please Wait." wait(1) script.Parent.Text = "4 Wagons" end end C70.MouseButton1Click:connect(C70Clicked)
Your problem is that you are trying to access the player from the server. This works fine in studio, but in the real game, the player's class is empty. The line
GUI = player.PlayerGui.MainMenuGui
would be the error point as the MainMenuGui would not exist from the server's point of view.
Hopefully this can clear some things up for you (the Remote Event works fine).