I found a few other issues, 1 second fixing them in studio so I can fix it easier and quicker; when I am done I will edit the script in here.
Edit:
local players = game:GetService("Players")
local plr1
local plr2
players.PlayerAdded:Connect(function(plr)
local function respawnFunc (char, plr)
print("Respawn function active for: "..plr.Name)
local humRP = char:WaitForChild("HumanoidRootPart")
local BG = Instance.new("BodyGyro")
-- please read more about BodyGyro's properties I put a link under the script.
BG.MaxTorque = Vector3.new(0,400000000,0)
-- BG.P = mess around with these 2 settings
-- BG.D =
BG.Parent = humRP
while char and char:FindFirstChild("Humanoid") and char.Humanoid.Health > 0 do
if plr1 and plr1 ~= plr then
if plr1.Character and plr1.Character:FindFirstChild("HumanoidRootPart") then
local otherHumRP = plr1.Character:FindFirstChild("HumanoidRootPart")
BG.CFrame = CFrame.new(humRP.Position,Vector3.new(humRP.Position.X,humRP.Position.Y,otherHumRP.Position.Z))
end
elseif plr2 and plr2 ~= plr then
if plr2.Character and plr2.Character:FindFirstChild("HumanoidRootPart") then
local otherHumRP = plr2.Character:FindFirstChild("HumanoidRootPart")
BG.CFrame = CFrame.new(humRP.Position,Vector3.new(humRP.Position.X,humRP.Position.Y,otherHumRP.Position.Z))
end
end
wait()
end
BG:Destroy()
end
if not plr1 then
plr1 = plr
plr.CharacterAdded:Connect(function(char) respawnFunc(char,plr) end)
print(plr.Name.." set as plr1")
elseif not plr2 then
plr2 = plr
plr.CharacterAdded:Connect(function(char) respawnFunc(char,plr) end)
print(plr.Name.." set as plr2")
end
end)
That should do it, I hope.
Edit 2:
- Sadly when I tried it, it did not work. I currently have no solution for fixing this; this is as far as I know how I could help you; maybe making the
MaxTorque
higher or editting with theBG.P
orBG.D
would work; tho I am not sure. - If this all won’t work then instead of setting the
BG.CFrame
set thehumRP.CFrame