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