Hello everyone!
i’m trying to make a draw board it’s work like what i want but everytime i send it Client
→ server
it’s give me wrong position with lines and dot
[Server]
[Client]
how it’s should be
--Client -> Server
ServerRemotes.Draw2d.SetCallback(function(a0: Player, a1: { Board: Model, Lines: {Vector2}, Points: {Vector2}, Size: {Vector2}, Rotation: {number}}) -- using zap for remote
local SurfaceGui: SurfaceGui = a1.Board.PrimaryPart.SurfaceGui
local DrawGui = a0.PlayerGui:FindFirstChild("DrawGui")
if not DrawGui then
warn("DrawGui it's not here")
return
end
for index, j in pairs(a1.Points) do
--Create dot
local Point = Instance.new("Frame", SurfaceGui.MainFrame)
Point.AnchorPoint = Vector2.new(0.5, 0.5)
local UI = Instance.new("UICorner", Point)
UI.CornerRadius = UDim.new(0, 99)
Point.Size = UDim2.fromOffset(35,35)
Point.Position = UDim2.fromScale(a1.Points[index].X, a1.Points[index].Y)
if a1.Lines[index] then -- Create line
local Lines = Instance.new("Frame", SurfaceGui.MainFrame.Lines)
Lines.AnchorPoint = Vector2.new(0.5, 0.5)
Lines.BorderSizePixel = 0
Lines.Rotation = a1.Rotation[index]
Lines.Position = UDim2.fromOffset(a1.Lines[index].X, a1.Lines[index].Y)
Lines.Size = UDim2.fromOffset(a1.Size[index].X, a1.Size[index].Y)
end
end
end)
--Create line
-- it's client not server
local function Connect_frames(
self: GetReflexData,
F1: Frame,
F2: Frame,
Frame: Frame
)
local guiInset = gui_service:GetGuiInset()
local screen_ui :ScreenGui = F1:FindFirstAncestorWhichIsA("ScreenGui")
local inset_enabled = screen_ui.IgnoreGuiInset
local F1Pos = F1.AbsolutePosition
local F1Size = F1.AbsoluteSize
local F1Center = F1Pos + (F1Size / 2)
local F2Pos = F2.AbsolutePosition
local F2Size = F2.AbsoluteSize
local F2Center = F2Pos + (F2Size / 2)
F1Center = F1Center + (inset_enabled and guiInset or Vector2.zero)
F2Center = F2Center + (inset_enabled and guiInset or Vector2.zero)
local Distance = Vector2.new(F1Center.X, F1Center.Y) - Vector2.new(F2Center.X, F2Center.Y)
local Difference = F1Center - F2Center
local CenterPosition = (F2Center + F1Center) / 2
Frame.Rotation = math.deg(math.atan2(Difference.Y, Difference.X))
Frame.Position = UDim2.fromOffset(CenterPosition.X, CenterPosition.Y)
Frame.Size = UDim2.fromOffset(Distance.Magnitude, F1.Size.X.Offset)
table.insert(self.Lines, Vector3.new(CenterPosition.X, CenterPosition.Y, 0))
table.insert(self.Size, Vector3.new(Distance.Magnitude, F1.Size.X.Offset, 0))
table.insert(self.Rotation, Frame.Rotation)
end
i’m sure the wrong with lines not with dot
and thank you <3