I’ve seen many other posts like this, they solve my problem a little. But they all have issues.
This is my current script, it works but only with 4x4 Gui’s, otherwise it just acts as a 4x4 hitbox when its not.
Also it allows you to clip in certain directions.
I made this from mashing some code together, anyone have a reliable GUI overlapping thing?
player:GetPropertyChangedSignal("Position"):Connect(function() -- checks for pos changing
local hitbox = gui.hitbox
local pos1, size1 = player.AbsolutePosition, player.AbsoluteSize;
local pos2, size2 = hitbox.AbsolutePosition, hitbox.AbsoluteSize;
local top = (pos1.Y) - (pos2.Y)
local bottom = (pos1.Y) - (pos2.Y)
local left = (pos1.X) - (pos2.X)
local right =(pos1.X) - (pos2.X)
local touching = false
if top < (size1.Y) and bottom < (size1.Y) and left < (size1.X) and right < (size1.X) then
player.Position = oldPosition
touching=true
player.dbug2.Text = "attempt to walk into wall"
wait(2)
player.dbug2.Text = "erroroutput: N/A"
end
return touching
end)
(PS: all the other gui overlapping things have the same issues.)