You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to get my script to work.
What is the issue?
I don’t know where the error is.
What solutions have you tried so far?
I couldn’t find any solutions.
local highestplayer
local highestdistance
if RoundTime == 0 then
for i,v in pairs(game.Players:GetPlayers()) do
local distance = v:DistanceFromCharacter(SelectedMap.EndPart.Position)
if v.Team == game.Teams.Game then
if v.Character.Completed == false then
if distance >= highestdistance then
highestdistance = distance
highestplayer = v.Name
end
end
end
end
local gamePlayers = {}
for i,v in pairs(game.Players:GetPlayers()) do
local Number = #gamePlayers + 1
if v.TeamColor == BrickColor.new("Really red") then
table.insert(gamePlayers,Number,v)
end
end
local highestplr = game.Players:FindFirstChild(highestplayer)
highestplr.Team = game.Teams.Lobby
if #gamePlayers == 1 then
game.Workspace.Board.SurfaceGui.TextLabel.Text = "Game ended! "..gamePlayers[1].Name.." won the game!"
wait(5)
end
Could someone help me with this script I already found out that the error is in this part but I can’t seem to find it.
Maybe that because currently your condition is checked only once but it is functional :
while wait() do
local highestplayer
local highestdistance
if RoundTime == 0 then
for i,v in pairs(game.Players:GetPlayers()) do
local distance = v:DistanceFromCharacter(SelectedMap.EndPart.Position)
if v.Team == game.Teams.Game then
if v.Character.Completed == false then
if distance >= highestdistance then
highestdistance = distance
highestplayer = v.Name
end
end
end
end
local gamePlayers = {}
for i,v in pairs(game.Players:GetPlayers()) do
local Number = #gamePlayers + 1
if v.TeamColor == BrickColor.new("Really red") then
table.insert(gamePlayers,Number,v)
end
end
local highestplr = game.Players:FindFirstChild(highestplayer)
highestplr.Team = game.Teams.Lobby
if #gamePlayers == 1 then
game.Workspace.Board.SurfaceGui.TextLabel.Text = "Game ended! "..gamePlayers[1].Name.." won the game!"
wait(5)
end
end
Glad that could help, that’s what I usually do in these situations and it’s quite effective. If you need help further now that you know the issue you could let us know and I’m sure someone will get back to you.