Runite
(Runite)
October 24, 2020, 8:20am
1
I working on a spar script, and when a team is eliminated, and their characters reset, the winning team is teleported to a spawn point. During the process, the teams are changed, and moved to overseers from an in-spar team. For some strange reason, when the winning team is teleported out, the leaderboard shows mixed teams on the winning team, and the losing team shows the correct team setup. Any reason why this would happen?
Here is what I am talking about:
jcnruad900
(jcnruad900)
October 24, 2020, 8:26am
2
May I ask if the script is local or normal?
Runite
(Runite)
October 24, 2020, 8:26am
3
The script is running Server-Side, in a model in workspace. Normal Script.
jcnruad900
(jcnruad900)
October 24, 2020, 8:27am
4
May I see it, to check for issues.
Runite
(Runite)
October 24, 2020, 8:28am
5
I tried running it a second time at the bottom to see if it needs to be further down.
script.Parent.reset.Changed:Connect(function()
if amountteam1.Value == 1 then
local player1 = workspace:FindFirstChild(stored.player1)
local root = player1:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 0, 0))
player1.links.playerlink.Value = 0
player1.links.spar_room.Value = 0
local findplayer = game.Players:GetPlayerFromCharacter(player1)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
elseif amountteam1.Value == 2 then
local player1 = workspace:FindFirstChild(stored.player1)
local player2 = workspace:FindFirstChild(stored.player2)
local root = player1:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 0, 0))
local root = player2:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 4, 0))
player1.links.playerlink.Value = 0
player1.links.spar_room.Value = 0
player2.links.playerlink.Value = 0
player2.links.spar_room.Value = 0
local findplayer = game.Players:GetPlayerFromCharacter(player1)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
local findplayer = game.Players:GetPlayerFromCharacter(player2)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
elseif amountteam1.Value == 3 then
local player1 = workspace:FindFirstChild(stored.player1)
local player2 = workspace:FindFirstChild(stored.player2)
local player3 = workspace:FindFirstChild(stored.player3)
local root = player1:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 0, 0))
local root = player2:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 4, 0))
local root = player3:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 8, 0))
player1.links.playerlink.Value = 0
player1.links.spar_room.Value = 0
player2.links.playerlink.Value = 0
player2.links.spar_room.Value = 0
player3.links.playerlink.Value = 0
player3.links.spar_room.Value = 0
local findplayer = game.Players:GetPlayerFromCharacter(player1)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
local findplayer = game.Players:GetPlayerFromCharacter(player2)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
local findplayer = game.Players:GetPlayerFromCharacter(player3)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
elseif amountteam1.Value == 0 then
else
print("ammount error in spar")
end
if amountteam2.Value == 1 then
local player4 = workspace:FindFirstChild(stored.player4)
local root = player4:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 0, 0))
player4.links.playerlink.Value = 0
player4.links.spar_room.Value = 0
local findplayer = game.Players:GetPlayerFromCharacter(player4)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
elseif amountteam2.Value == 2 then
local player4 = workspace:FindFirstChild(stored.player4)
local player5 = workspace:FindFirstChild(stored.player5)
local root = player4:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 0, 0))
local root = player5:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 4, 0))
player4.links.playerlink.Value = 0
player4.links.spar_room.Value = 0
player5.links.playerlink.Value = 0
player5.links.spar_room.Value = 0
local findplayer = game.Players:GetPlayerFromCharacter(player4)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
local findplayer = game.Players:GetPlayerFromCharacter(player5)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
elseif amountteam2.Value == 3 then
local player4 = workspace:FindFirstChild(stored.player4)
local player5 = workspace:FindFirstChild(stored.player5)
local player6 = workspace:FindFirstChild(stored.player6)
local root = player4:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 0, 0))
local root = player5:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 4, 0))
local root = player6:FindFirstChild("HumanoidRootPart")
root.CFrame = CFrame.new(movespawn.Position + Vector3.new(0, 8, 0))
player4.links.playerlink.Value = 0
player4.links.spar_room.Value = 0
player5.links.playerlink.Value = 0
player5.links.spar_room.Value = 0
player6.links.playerlink.Value = 0
player6.links.spar_room.Value = 0
local findplayer = game.Players:GetPlayerFromCharacter(player4)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
local findplayer = game.Players:GetPlayerFromCharacter(player5)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
local findplayer = game.Players:GetPlayerFromCharacter(player6)
local Sword = findplayer.Backpack:FindFirstChild('ASR 3.0')
if (Sword) then
Sword:Destroy()
end
findplayer.TeamColor = BrickColor.new("Really black")
elseif amountteam2.Value == 0 then
else
print("ammount error in spar")
end
local player1 = workspace:FindFirstChild(stored.player1)
local player2 = workspace:FindFirstChild(stored.player2)
local player3 = workspace:FindFirstChild(stored.player3)
local player4 = workspace:FindFirstChild(stored.player4)
local player5 = workspace:FindFirstChild(stored.player5)
local player6 = workspace:FindFirstChild(stored.player6)
local findplayer1 = game.Players:GetPlayerFromCharacter(player1)
local findplayer2 = game.Players:GetPlayerFromCharacter(player2)
local findplayer3 = game.Players:GetPlayerFromCharacter(player3)
local findplayer4 = game.Players:GetPlayerFromCharacter(player4)
local findplayer5 = game.Players:GetPlayerFromCharacter(player5)
local findplayer6 = game.Players:GetPlayerFromCharacter(player6)
findplayer1.TeamColor = BrickColor.new("Really black")
findplayer2.TeamColor = BrickColor.new("Really black")
findplayer3.TeamColor = BrickColor.new("Really black")
findplayer4.TeamColor = BrickColor.new("Really black")
findplayer5.TeamColor = BrickColor.new("Really black")
findplayer6.TeamColor = BrickColor.new("Really black")
jcnruad900
(jcnruad900)
October 24, 2020, 8:33am
6
Not sure about what causes the issue, but consider using a for loop so there aren’t many if and elseif. EDIT: With a for loop you can cut 75% of the code.
Runite
(Runite)
October 24, 2020, 8:37am
7
I do plan on re-writing this code in a streamlined manner to reduce it, but I just am doing trial and error at the moment.
jcnruad900
(jcnruad900)
October 24, 2020, 8:40am
8
Also you may need to try a test with an actual player, to check if it’s just an engine replication bug or a bug in the script.
Runite
(Runite)
October 24, 2020, 8:43am
9
You mean like uploaded to website? I have tried testing with 2-6 clients in studio, and same error occurs but with just an increased number of clients.
jcnruad900
(jcnruad900)
October 24, 2020, 8:44am
10
Yeah try to publish it and test with another player.
It’s hard to tell what the issue is, mainly because you’re so heavily violating the D.R.Y principle ( Do not repeat yourself) even if you need to use that many if statements, you should still call a function. I think the issue is likely with a specific if statement, and if you convert it to a function it might fix.
EDIT: You also might want to check if you have anything else changing teams
Runite
(Runite)
October 24, 2020, 10:17am
12
Update: Fixed, will be streamlining the scripts soon.