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):
01 | train = game.ReplicatedStorage.C 70 Freight |
02 | Camera = workspace.CurrentCamera |
03 | DriveFrame = GUI.Screen.DriveFrame |
04 | Spawning = GUI.Screen.Spawning |
05 |
06 | script.Parent.Parent.Events.C 70 Spawn.OnServerEvent:connect( function (player) |
07 | GUI = player.PlayerGui.MainMenuGui |
08 | DriveFrame.Visible = false |
09 | Spawning.Visible = true |
10 | Spawning.Text = "Spawning..." |
11 | wait( 0.01 ) |
12 | local clone = train:Clone() |
13 | clone.Parent = workspace |
14 | clone:MakeJoints() |
15 | wait( 1 ) |
LocalScript (in Gui)
01 | Frame = script.Parent.Parent |
02 | C 70 = Frame:WaitForChild( "Set1" ) |
03 | Player = game.Players.LocalPlayer |
04 |
05 | function C 70 Clicked() |
06 | if workspace:IsRegion 3 Empty(Region 3. new(Vector 3. new( 467.505 , 6.548 , - 3076.283 ), Vector 3. new( 1152.544 , 6.559 , - 3298.865 ))) then |
07 | game.ReplicatedStorage.Events.C 70 Spawn:FireServer() |
08 | else |
09 | script.Parent.Text = "Spawn Occupied! Please Wait." |
10 | wait( 1 ) |
11 | script.Parent.Text = "4 Wagons" |
12 | end |
13 | end |
14 |
15 | C 70. MouseButton 1 Click:connect(C 70 Clicked) |
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
1 | 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).