Categories > Coding > Lua >

Infinite respawn Bug

Posts: 3

Threads: 3

Joined: Dec, 2023

Reputation: 0

Posted

local function reload(plr)
	plr:WaitForChild("TrollCooldown").Value = true
	plr:LoadCharacter()
	
	local success, err = pcall(function()
		game:GetService("ReplicatedStorage").Trolls:FindFirstChild(plr:WaitForChild("Troll").Value):Clone()
	end)
	
	if err then
		plr:WaitForChild("Troll").Value = "Troll"
	end
	local troll = game:GetService("ReplicatedStorage").Trolls:FindFirstChild(plr:WaitForChild("Troll").Value):Clone()	
	
	for i,v in pairs(troll:GetChildren()) do
		local trollclone = v:Clone()
		local trollstats = v:FindFirstChild("TrollStats")
		local trollweapon = game.ReplicatedStorage.TrollWeapons:FindFirstChild(plr:WaitForChild("Troll").Value):Clone()
		
		trollclone.Parent = game.Workspace
		trollclone.Name = plr.Name
		trollclone.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame
		plr.Character = trollclone
		
		plr.Character:WaitForChild("Animate"):Destroy()
		v:FindFirstChild("Animate").Parent = plr.Character
		local CameraFixer = script.CameraFixer:Clone()
		CameraFixer.Disabled = false
		CameraFixer.Parent = plr:WaitForChild("PlayerGui")
		
		for i,v in pairs(trollweapon:GetChildren()) do
			v.Parent = plr.Backpack
		end
		trollweapon:Destroy()
		plr.TrollRarity.Value = trollstats.Rarity.Value
		local Humanoid = plr.Character:WaitForChild("Humanoid")
		Humanoid.MaxHealth = trollstats.Health.Value
		Humanoid.Health = trollstats.Health.Value
		Humanoid.WalkSpeed = trollstats.Walkspeed.Value
		Humanoid.JumpPower = trollstats.JumpPower.Value
		if plr.Character:FindFirstChild("Awaken") then
			plr.Character:FindFirstChild("Awaken").Disabled = false
		end
		
		if plr.Character.Head:FindFirstChild("HealthGui") then
			plr.Character.Head:FindFirstChild("HealthGui"):Destroy()
		end
		
		local healthgui = game.ReplicatedStorage.Trolls.HealthGui:Clone()
		healthgui.Parent = plr.Character.Head
		healthgui.Script.Disabled = false
		
		troll:Destroy()
		plr:WaitForChild("TrollCooldown").Value = false
			Humanoid.Died:Connect(function()
			wait(3)
			plr:LoadCharacter()
		end)
	end
end

 

After dying/reseting character, it will infinitly load your character until you leave the game. Been trying to figure out why for an hour now.

It sends no errors to output so its very confusing.

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )