Ui minigame ( Ui Detection )

So I making this ui minigame in my game but the problem is detection(I dont think it is) I found another post on it and I understand the detection perfectly personally I think its the way I’m moving the ui.
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Players = game:GetService(“Players”)
local UserInputService = game:GetService(“UserInputService”)
local TweenService = game:GetService(“TweenService”)

local StopFunction = ReplicatedStorage.Stop

local PlayerTweens = {}

function areFramesOverlapping(Frame1,Frame2)
local F1posX,F2posX = Frame1.AbsolutePosition.X,Frame2.AbsolutePosition.X
local F1sizeX,F2sizeX = Frame1.AbsoluteSize.X,Frame2.AbsoluteSize.X

local Xdistance = math.abs(F1posX-F2posX) -- distance (in px) between frames
local minXdistance = math.abs(F1sizeX+F2sizeX/2)-- min distance w/o overlap

if  Xdistance < minXdistance then return true end --

return false -- no overlap detected

end

Players.PlayerAdded:Connect(function(player)

local Moving = player.PlayerGui:WaitForChild("ScreenGui").Main.MovingFrame
local StillFrame = player.PlayerGui:WaitForChild("ScreenGui").StillFrame

local MoveTween = TweenService:Create(Moving , TweenInfo.new(1 , Enum.EasingStyle.Linear , 	Enum.EasingDirection.InOut , math.huge , true),{Position = UDim2.new(0.98 ,0 , 0 , 0)})
MoveTween:Play()
PlayerTweens[player.UserId] = MoveTween

end)

StopFunction.OnServerInvoke = function(player)

local Moving = player.PlayerGui:WaitForChild("ScreenGui").Main.MovingFrame
local StillFrame = player.PlayerGui:WaitForChild("ScreenGui").StillFrame

local Tween = PlayerTweens[player.UserId]

local PositionUi = Moving.Position
Tween:Pause()
Moving.Position = PositionUi

print(areFramesOverlapping(Moving , StillFrame))

task.wait(.65)

Tween:Play()

end

1 Like

are you sure it shouldn’t be (a+b)/2
local minXdistance = math.abs((F1sizeX+F2sizeX)/2)
or
local minXdistance = math.abs(F1sizeX+F2sizeX)/2

I didn’t think there would be a difference even if it was - or +

right now you’re doing this:
local minXdistance = math.abs(F1sizeX+(F2sizeX/2))

it doesnt matter if its - or +

to be more in depth so basically eight before the still frame (win) and at the end of the still frame (inside : loss )

same results either way… I think

i didnt tell you to use this

i told you what you’re doing right now

try doing this, like i said in my reply before

Yea I tried that already yeilds same results

Can’t you just do

local minXdistance = stillFrameSizeX/2