Library stuck in a loop with an error pointing to an OR statement. Added a ton of junk data to the module

  1. What do you want to achieve? Make my 4D engine I was going to release as part of Project Sand Cat as a demo for what libraries and games will stem from what I will release when the 4D engine I was developing was done. I am making the 4D engine because I need to practice scripting.

  2. What is the issue? After the limit for size gets exceeded 2 times and will call itself 2 times when the increase4d function is called once it will not change the size of an object and will just error on the else function 4997 times. First time it did this it filled the module with the log when moving my mouse around.

  3. What solutions have you tried so far? I haven’t tried any yet. I am afraid to crash my laptop and corrupt Windows.

This is the code that was giving me issues

local function changeSize(object)
	local defaultSize = get4d(object)[2]
	local newSize = Vector3.new(defaultSize.X + get4d(object)[3],defaultSize.Y + get4d(object)[3],defaultSize.Z + get4d(object)[3])
	object.Size = newSize
end

function module.change4D(object, isAddition, number)
	local function add(bool, intvalue)
		if isAddition then
			if get4d(object)[3] > module.MaximumSize or (get4d(object)[3] + intvalue) > module.MaximumSize then
				local correctValue = (get4d(object)[3] + intvalue) - module.MaximumSize
				add(false,correctValue)
			else
				get4d(object)[3] += intvalue
			end
		else
			if get4d(object)[3] < -module.MaximumSize or (get4d(object)[3] - intvalue) < -module.MaximumSize then
				local correctValue = (get4d(object)[3] - intvalue) + module.MaximumSize
				add(true,correctValue)
			else
				get4d(object)[3] -= intvalue
			end
		end
	end
	if is4d(object) then
		add(isAddition, number)
		changeSize(object)
	else
		error("Expected 4D object, not 3D object.")
	end
end

I ran this until it would be the first time it gets the correctValue and returns it is also over 10 so it would reset back to 0 but it just doesn’t

_G["4DService"].change4D(game.Workspace.Baseplate, true, 11)
1 Like

I found that adding some waits fixed one bug and I can fix the other easily
I used the wrong var so it errored

You’re going to have to describe what the hell a 4D engine is meant to be. There’s a lot of context we’re missing to give you any amount of useful advice here.

Except this - I assure you, no matter how terrible some code is on Roblox, you’re not going to crash Windows with it, so don’t be afraid to try things. At worst, you’ll need to use Task Manager to force-close Roblox Studio.