Why does my script never print Hi?

I’m trying to make a UI physics engine but my script never prints “HI” any help?

local rs = game:GetService("RunService")
	if script.Parent:FindFirstChild("Cube") then
		for index, instance in pairs(script.Parent:GetDescendants()) do 
			if instance.Name == "Hit" then
				local tall = script.Parent.Cube.AbsoluteSize.Y
				local bottomFACE = tall / 2
				local bottom = script.Parent.Cube.AbsolutePosition.Y - bottomFACE
				local HITtall = instance.AbsoluteSize.Y
				local HITtopFACE = tall / 2
				local HITtop = instance.AbsolutePosition.Y + HITtopFACE
				if bottom == HITtop then

Are you sure that the script is reaching the last if statement? I would add more prints after every if statement to make sure that none of them are failing first.


You should try to add a print that prints HITtop and bottom, print(HITtop, bottom), and make sure that they match. If they don’t match the if won’t be true and “hi” won’t be printed. Make sure not to put this print inside the if statement. If they’re off just slightly (eg. 1.1005, 1.1009) you can use math.round() to round them.

1 Like

Yeah I should have thought of that I’ll try later.

I used math.round and the numbers went from 360 and 360.00558676 to 360 and 170?

What are you rounding the numbers to? If you want to round 360.00558676 to 360 do this: math.round(360.00558676, 360) This will round the number to 360.

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