Studio crashes when testing

Before you say it, I don’t have access to bug reports

In studio, everytime I play a game it crashes, whether i click play, play here or run. For some reason, it works if i use team test, but not normal.
I’ve tried changing the rendering mode and reading through all the scripts, but it doesn’t work. T
his issue only started today when I copied my game to a new group, it worked fine before and I didn’t add anything.
This bug is only on this place, since other games of mine work I don’t know why it happens. It requires me to quit studio every time.

Have you looked through assets and made sure there is nothing that could be causing the crash?

Yes, I haven’t found anything.

By disabling and enabling every single script, and combing through parts I found out the script that was causing the error, but I don’t see where the Problem is

Script:

local e = require(script.ZombieBehaviour)

print(e.new())

ModuleScript:

local Pathfinding = require(script.Pathfinding)
local ZombieTypes = require(script.Parent.ZombieTypes)

local ZombModels = game:FindService("ServerStorage"):GetChildren()
local SpawnPoints--= workspace.ZombieSpawns:GetChildren()

local RNG = Random.new()

local Zombie = {}
Zombie.__type = "ZombieBehaviour"

local function GetDistance(var1, var2)
	if typeof(var1) == "Vector3" then
		return (var1-var2).Magnitude
	elseif typeof(var1) == "Instance" then
		return (var1:GetPivot().Position-var2:GetPivot().Position).Magnitude
	end
end

function InitCheck(properties:{})
	local Type, Health, Speed = properties.Type, properties.Health, properties.Speed
	local Model = properties.Model
	local hum = Model:FindFirstChildOfClass("Humanoid")
	if not hum then
		hum = Instance.new("Humanoid", Model)
		local animator = Instance.new("Animator", hum)
	elseif hum and not hum:FindFirstChildOfClass("Animator") then
		local animator = Instance.new("Animator", hum)
	end
	hum.MaxHealth, hum.Health = Health, Health
	hum.WalkSpeed = Speed
	return {
		Instance=Model, 
		Humanoid = hum, 
		Animator = hum.Animator,
		Path = Pathfinding.new(Model, {
			AgentRadius = 2.0;
			AgentHeight = hum.HipHeight
		}),
		_attacking = false
	}
end

function Zombie.new(zomb)
	local NewZombie = zomb or ZombieTypes[RNG:NextInteger(1, #ZombieTypes)]
	print(NewZombie)
	NewZombie = InitCheck(NewZombie)

	coroutine.wrap(function()
		while true do
			local NearestChar = Pathfinding.GetNearestCharacter(NewZombie.Instance:GetPivot().Position)
			NewZombie.Path:Run(NearestChar)
			if GetDistance(NewZombie.Instance, NearestChar) then
				NewZombie:Attack(NearestChar)
			end
			task.wait()
		end
	end)

	return setmetatable(NewZombie, Zombie)
end

function Zombie:Attack(target)
	print('attack!')
end

function Zombie:Die()

end




return Zombie
2 Likes

The problem might be that there actually isn’t a new in the ModuleScript

You can see function Zombie.new()

That’s Zombie.new, not new, but I might be wrong

Do you know how metatables work…

They are a table attached to a table, if you get what I mena

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.