Placement System

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 :slight_smile:


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))
1 Like

by using GameProcessed flag in InputBegan or whatever you are using to make sure it doesnt sink when other interactive ui elements are triggered

4 Likes

Thank you so much bro i thought GPE only detects whether a player on TextBox Focused
OMG im so dumb i didn’t even tried to check it

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.