What’s the best way to solve this issue? I want to make the object to stay where the last mouse location is if they pressed a guibutton, but it seems like it didn’t work. Thanks in advance ![]()
Code:
table.insert(self.Scope, RunService.PreRender:Connect(function()
if self.CurrentPreview == nil then
return
end
local mouse_loc = UserInputService:GetMouseLocation()
for _, v in client_player.PlayerGui:GetGuiObjectsAtPosition(mouse_loc.X, mouse_loc.Y) do
if v:IsA("GuiButton") and v:FindFirstAncestor("ContextButtonFrame") and v.Active then
mouse_loc = self.LastMouseLoc
break
end
end
self.LastMouseLoc = mouse_loc
local cast = self.Mouse:Raycast(self.RayParams, 1000, mouse_loc)
if not cast then
return
end
self.PreviewPos:set(self:_snapToWorldGrid(cast))
self.CanPlace:set(PlacementUtil.CanPlace(self.Grid, self.CurrentPreview:GetPivot(), HelperUtil.GetSize(self.CurrentPreview, true)))
end))
