Player:LoadCharacter not working in RemoteEvent?
Asked by
6 years ago Edited 6 years ago
So I'm making a FPS game right now. I have two number values in a folder in Rep Storage representing the score values (number of kills) of the two teams. I also have it so that if a team has a score greater or equal to 30 it will fire a remote event to all clients giving the name of the winning team. That clients then show a GUI showing which team won the game. The clients then fire a remote event telling the player to LoadCharacter(). Unfortunately the player does not LoadCharacter() whenever I test it. Can anyone please help?
The regular script
03 | if game:GetService( "ReplicatedStorage" ):WaitForChild( "ScoreValues" ):WaitForChild( "RedScoreValue" ).Value > = 30 then |
04 | game:GetService( "ReplicatedStorage" ):WaitForChild( "EndGameEvent" ):FireAllClients( "Red" ) |
06 | game:GetService( "ReplicatedStorage" ):WaitForChild( "ScoreValues" ):WaitForChild( "RedScoreValue" ).Value = 0 |
07 | game:GetService( "ReplicatedStorage" ):WaitForChild( "ScoreValues" ):WaitForChild( "BlueScoreValue" ).Value = 0 |
09 | if game:GetService( "ReplicatedStorage" ):WaitForChild( "ScoreValues" ):WaitForChild( "BlueScoreValue" ).Value > = 30 then |
10 | game:GetService( "ReplicatedStorage" ):WaitForChild( "EndGameEvent" ):FireAllClients( "Blue" ) |
12 | game:GetService( "ReplicatedStorage" ):WaitForChild( "ScoreValues" ):WaitForChild( "RedScoreValue" ).Value = 0 |
13 | game:GetService( "ReplicatedStorage" ):WaitForChild( "ScoreValues" ):WaitForChild( "BlueScoreValue" ).Value = 0 |
17 | game:GetService( "ReplicatedStorage" ):WaitForChild( "EndGameEvent" ).OnServerEvent:Connect( function (player) |
18 | player:LoadCharacter() |
The local script
01 | game:GetService( "ReplicatedStorage" ):WaitForChild( "EndGameEvent" ).OnClientEvent:Connect( function (winner) |
02 | script.Parent.Enabled = true |
03 | script.Parent:WaitForChild( "Win" ).Text = "Team " ..winner.. " won the game!" |
04 | if winner = = "Red" then |
05 | script.Parent:WaitForChild( "Win" ).BackgroundColor 3 = Color 3. new( 255 , 0 , 0 ) |
06 | elseif winner = = "Blue" then |
07 | script.Parent:WaitForChild( "Win" ).BackgroundColor 3 = Color 3. new( 0 , 0 , 255 ) |
10 | script.Parent.Enabled = false |
11 | game:GetService( "ReplicatedStorage" ):WaitForChild( "EndGameEvent" ):FireServer(game:GetService( "Players" ).LocalPlayer) |