This is the main part I have a question on. Did I correctly use my ifs and elses?
script.Parent.Touched:connect(function(hit) Player2 = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent.Parent:findFirstChild("Humanoid") then if game.ServerStorage.DoesArena1Have2Players.Value == 2 then return end else if game.ServerStorage.DoesArena1Have2Players.Value <= 1 then game.ServerStorage.DoesArena1Have2Players.Value = game.ServerStorage.DoesArena1Have2Players.Value+1
debounce = false script.Parent.Touched:connect(function(hit) Player2 = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent.Parent:findFirstChild("Humanoid") then if game.ServerStorage.DoesArena1Have2Players.Value == 2 then return end else if game.ServerStorage.DoesArena1Have2Players.Value <= 1 then game.ServerStorage.DoesArena1Have2Players.Value = game.ServerStorage.DoesArena1Have2Players.Value+1 if debounce == true then return end debounce = true Char = hit.Parent Char.Torso.CFrame = CFrame.new(game.Workspace.tele.Position + Vector3.new(0, 5, 0)) debounce = false m = Instance.new("Message", workspace) m.Text = "Get Ready to Fight!" wait(5) m:Destroy() game.ReplicatedStorage["Sword"]:clone().Parent = Player2.Backpack end end end)
Did I correctly end my code?
I fixed your indenting and fix your code, when using "else" it always goes before the end of the if function. NOT TESTED
script.Parent.Touched:connect(function(hit) Player2 = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent.Parent:findFirstChild("Humanoid") then if game.ServerStorage.DoesArena1Have2Players.Value == 2 then return elseif game.ServerStorage.DoesArena1Have2Players.Value <= 1 then game.ServerStorage.DoesArena1Have2Players.Value = game.ServerStorage.DoesArena1Have2Players.Value+1 end
debounce = false script.Parent.Touched:connect(function(hit) Player2 = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent.Parent:findFirstChild("Humanoid") then if game.ServerStorage.DoesArena1Have2Players.Value == 2 then return elseif game.ServerStorage.DoesArena1Have2Players.Value <= 1 then game.ServerStorage.DoesArena1Have2Players.Value = game.ServerStorage.DoesArena1Have2Players.Value+1 end if debounce == true then return end debounce = true Char = hit.Parent Char.Torso.CFrame = CFrame.new(game.Workspace.tele.Position + Vector3.new(0, 5, 0)) debounce = false m = Instance.new("Message", workspace) m.Text = "Get Ready to Fight!" wait(5) m:Destroy() game.ReplicatedStorage["Sword"]:clone().Parent = Player2.Backpack end end)