Hi guys, I was making a 1v1 system, when another unusual problem popped up:
THE PROBLEMATIC LINE IS AT AROUND 107-108!
The purpose of this script is to TP the players into the arena, then freeze them (In order for them to prevent moving) and then once the timer reaches zero, unfreeze them. Now, I wanted to make a round system (So that you could configure how many rounds a certain match should have) it works fine, but I want it so that once the player RESPAWNS, He/she tps back into the arena. For some really weird reason, Roblox READS those lines without ANY error, it even* PRINTS* what I've put in there. But it doesn't tp the players back in. Output is what is expected, the only problem is that it doesn't teleport the players back in. For some weird reason.
local pressed = false
function main()
if not pressed then
pressed = true
local announce = Instance.new("Hint", game.Workspace)
print("[D] MasterScript: Setting config path")
local config = game.Workspace.Configurations
print("[D] MasterScript: Setting Plate path")
local Plate1 = game.Workspace.Plate1
local Plate2 = game.Workspace.Plate2
print("[D] MasterScript: Setting Plate Teleport Path")
local Tele1 = game.Workspace.Plate1_teleport
local Tele2 = game.Workspace.Plate2_teleport
print("[D] MasterScript: Checking if Players are still here...")
local Player1 = game.Workspace:FindFirstChild(Plate1.whostepped.Value)
local Player2 = game.Workspace:FindFirstChild(Plate2.whostepped.Value)
print("[D] MasterScript: Checking fight dependencies")
local SwordTemplate = game.ReplicatedStorage.ClassicSword
if Plate1.stepped.Value == true and Plate2.stepped.Value == true then -- Checks if both players stepped on the plate
local rounds = config.RoundNumber.Value
if Player1 == nil then
print("[D] MasterScript: Player 1 left! Cancel game!")
announce.Text = ("Player 1 left. Game cannot continue!")
wait(2)
announce.Text = ""
return
end
if Player2 == nil then
print("[D] MasterScript: Player 2 left! Cancel game!")
announce.Text = ("Player 2 left. Game cannot continue!")
wait(2)
announce.Text = ""
return
end
announce.Text = ("Game commencing with "..Player1.Name.." and "..Player2.Name)
wait(2)
announce.Text = ("With a total of "..config.RoundNumber.Value.." rounds")
Player1.Torso.Anchored = true
Player2.Torso.Anchored = true
Player1:MoveTo(Tele1.Position) -- Teleports them inside the arena.
Player2:MoveTo(Tele2.Position)
Plate1.stepped_script.Disabled = true
Plate2.stepped_script.Disabled = true
wait(2)
for i = 7, 0, -1 do
wait(1)
announce.Text = i.." seconds remaining!"
end
announce.Text = "Fight!"
local Player1plr = game.Players:GetPlayerFromCharacter(Player1)
local Player2plr = game.Players:GetPlayerFromCharacter(Player2)
local Player1Sword = SwordTemplate:Clone()
local Player2Sword = SwordTemplate:Clone()
Player1Sword.Parent = Player1plr.Backpack
Player2Sword.Parent = Player2plr.Backpack
Player1.Torso.Anchored = false
Player2.Torso.Anchored = false
while config.RoundNumber.Value ~= 0 do
wait()
while Player1:WaitForChild("Humanoid").Health ~= 0 and Player2:WaitForChild("Humanoid").Health ~= 0 do
wait()
announce.Text = "Game in progress with "..Player1.Name.." and "..Player2.Name.." with "..config.RoundNumber.Value.." rounds"
end
if Player1.Humanoid.Health == 0 then
announce.Text = Player2.Name.." wins this round"
config.RoundNumber.Value = config.RoundNumber.Value - 1
wait(12)
else
announce.Text = Player1.Name.." wins this round"
config.RoundNumber.Value = config.RoundNumber.Value - 1
wait(12)
end
print("[D] MasterScript: Clearing backpacks")
Player1plr.Backpack:ClearAllChildren()
Player2plr.Backpack:ClearAllChildren()
print("[D] MasterScript: Backpacks cleared")
Player1:MoveTo(Vector3.new(1,1,1))
Player2:MoveTo(Vector3.new(1,1,1))
wait()
print(Player1.Name.." and "..Player2.Name)
Player1:MoveTo(game.Workspace.Plate1_teleport.Position) -- PROBLEMATIC LINE!
print("[D] MasterScript: Successfully moved Player1 back")
Player2:MoveTo(game.Workspace.Plate2_teleport.Position)
print("[D] MasterScript: Successfully moved Player2 back")
Player1.Torso.Anchored = true
Player2.Torso.Anchored = true
for i = 5, 0, -1 do
wait(1)
announce.Text = i.." second intermission"
end
Player1.Torso.Anchored = false
Player2.Torso.Anchored = false
announce.Text = "Fight!"
local Player1Sword = SwordTemplate:Clone()
local Player2Sword = SwordTemplate:Clone()
Player1Sword.Parent = Player1plr.Backpack
Player2Sword.Parent = Player2plr.Backpack
end
end
end
pressed = false
end
workspace.Plate1.Touched:connect(main)
workspace.Plate2.Touched:connect(main)
I'm just flabbergasted now. I don't understand what's going wrong with it. Maybe it's my stupidity or something, but I'm not giving up so quick. I need your help though. Please help me, This is getting ridiculous. If you need the full code I can give it to you.
Edit: Formatting

1 comment
You could try changing the Torso's position