For some reason, this script doesn't work even though no errors are printed
script.Parent.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent)then if game.ReplicatedStorage.Teams.Value == 0 hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -88.617, -67))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 if game.ReplicatedStorage.Teams.Value == 1 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -90.617, 49.5))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 if game.ReplicatedStorage.Teams.Value == 2 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -88.617, -67))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 if game.ReplicatedStorage.Teams.Value == 3 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -90.617, 49.5))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 if game.ReplicatedStorage.Teams.Value == 4 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -88.617, -67))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 if game.ReplicatedStorage.Teams.Value == 5 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -90.617, 49.5))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 end end end)
Its meant to divide 6 players into 2 teams, with each of the 2 teleport spots being the team bases. If the number is odd then they are on the blue team but if it's even they are on the green team, every time someone touches the block the number goes up by one. If the script is sloppy I'm sorry, I'm new to scripting. It teleports the player when they touch the block. But for some reason, it isn't teleporting them.
Also if anyone has a more organized version of the script I would gladly use it.
So, If you know why this isn't working, could you help me, please?
If statements start with an if, and always terminate with end. You should not put another if statement unless it is nested within the first one, or you have already ended the first one. What you can put between the if and end is elseif.
Try this:
script.Parent.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent)then if game.ReplicatedStorage.Teams.Value == 0 hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -88.617, -67))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 elseif game.ReplicatedStorage.Teams.Value == 1 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -90.617, 49.5))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 elseif game.ReplicatedStorage.Teams.Value == 2 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -88.617, -67))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 elseif game.ReplicatedStorage.Teams.Value == 3 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -90.617, 49.5))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 elseif game.ReplicatedStorage.Teams.Value == 4 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -88.617, -67))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 elseif game.ReplicatedStorage.Teams.Value == 5 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(60.293, -90.617, 49.5))--Change to Position game.ReplicatedStorage.Teams.Value = game.ReplicatedStorage.Teams.Value + 1 end end end)