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
while true do
wait(1)
if game:GetService("ReplicatedStorage"):WaitForChild("ScoreValues"):WaitForChild("RedScoreValue").Value >= 30 then
game:GetService("ReplicatedStorage"):WaitForChild("EndGameEvent"):FireAllClients("Red")
wait(10)
game:GetService("ReplicatedStorage"):WaitForChild("ScoreValues"):WaitForChild("RedScoreValue").Value = 0
game:GetService("ReplicatedStorage"):WaitForChild("ScoreValues"):WaitForChild("BlueScoreValue").Value = 0
end
if game:GetService("ReplicatedStorage"):WaitForChild("ScoreValues"):WaitForChild("BlueScoreValue").Value >= 30 then
game:GetService("ReplicatedStorage"):WaitForChild("EndGameEvent"):FireAllClients("Blue")
wait(10)
game:GetService("ReplicatedStorage"):WaitForChild("ScoreValues"):WaitForChild("RedScoreValue").Value = 0
game:GetService("ReplicatedStorage"):WaitForChild("ScoreValues"):WaitForChild("BlueScoreValue").Value = 0
end
end
game:GetService("ReplicatedStorage"):WaitForChild("EndGameEvent").OnServerEvent:Connect(function(player)
player:LoadCharacter()
end)
The local script
game:GetService("ReplicatedStorage"):WaitForChild("EndGameEvent").OnClientEvent:Connect(function(winner)
script.Parent.Enabled = true
script.Parent:WaitForChild("Win").Text = "Team "..winner.." won the game!"
if winner == "Red" then
script.Parent:WaitForChild("Win").BackgroundColor3 = Color3.new(255, 0, 0)
elseif winner == "Blue" then
script.Parent:WaitForChild("Win").BackgroundColor3 = Color3.new(0, 0, 255)
end
wait(10)
script.Parent.Enabled = false
game:GetService("ReplicatedStorage"):WaitForChild("EndGameEvent"):FireServer(game:GetService("Players").LocalPlayer)
end)
