This is my first code after about a 7 month hiatus, so I'm expecting there's some stupid mistake causing this. Whenever I run this script (play or just the regular run, both within studio) it loads the place half way, then the entire thing stops, and without any output or error messages, it freezes permanently and I have to use task manager to close it.
I have marked the line that seems to be the issue (if I purposely make a mistake, such as a lowercase "V" in value, it doesn't crash). Everything above this line runs just fine. Because of this strange catch, I'm not sure if it's an issue with my code or with the software, but my code is the only thing I can double check.
Thanks for reading, and here's the code (if you need any additional info, just leave a comment) --
local x = script.Parent.Position.X; -- hierarchy is Block --> Initrun(bool value), Script(this script) --> MaxDistance(number value), closeMultiplier(number value)
local y = script.Parent.Position.Y + 4;
local z = script.Parent.Position.Z;
local mdist = script.MaxDistance.Value;
local limitnum = mdist * script.closeMultiplier.Value;
local xs = script.Parent.Size.X;
local zs = script.Parent.Size.Z;
local initial = script.Parent.Initrun.Value;
local waittime = game.Lighting.ototal.respawn.Value; -- an integer value
local limit;
repeat -- the true start
if initial == false then
limit = math.floor(((zs + xs)/2)/limitnum); -- creates the aforementioned "local limit"
print(limit);
initial = true;
elseif game.Lighting.ototal.Value > limit then -- Integer value, I also suspect this is the line causing issues.
wait(waittime)
else
ospawn()
end
function ospawn()
print("Spawned!")
end
until nil

1 comment
Ah, I didn't see that. I got a bit ahead of myself with testing the script then, since I'll have ways to wait later on. As for the function, I've never had an issue calling one higher in the script than its creation -- I'll keep it in mind though! Thanks for the help.