Locking a GUI in place while moving?

So basically I’m trying to lock this GUI in place while the player is moving and just lock it in the middle of the screen or somewhere near there that would look good. I hope you can see the effect I’m going at but I really have no clue where to start with this. (It’s a billboard gui/surface gui)

Here is a video of what I mean:

I’ve tried welding and a few other random fixes that haven’t come close to working.
I’m really just looking for how to get this done or where to start with doing this correctly.

2 Likes

Why not use a ScreenGui object in StarterGui?

Well, I’m going for a different type of design. I seen something in a discord and I’m trying to recreate it. This design looks better overall.

Maybe use user input service and detect when the mouse is pressed the GUI is in a specific place, and end it with the user ended(I think that’s what it’s called) and it will return to normal. I can’t test this out cause I don’t have the script

Mind explaining it a bit more in depth? I don’t really understand what you mean. Also the script really is just a mouse lock and makes the FOV 50.

But only if you answer this question: is the gun activated when the mouse button is down?

Basically, the camera lock script turns on when F is pressed. I am going to end up making this camera system turn on automatically but I’m just testing right now. Right clicking during this will activate this camera zoom and etc.

so what activates the gun firing?

Clicking fires the gun and shoots.

so you would put this as the local script and put it in the gun:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function(plr)
    [Reference your GUI using plr].Position = UDim2.new(where you want it to be) -- the plr is the player, and to reference the startergui you would need to use plr:WaitForChild("PlayerGui")
end)
1 Like

So basically I would need constantly changing position values, the GUI will need to be changing with the players position and where the player is looking.

no, the script just forces the Gui to be in that position until the mouse button is lifted

you can use this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Out = false

mouse.Button1Down:Connect(function(plr)
    Out = false
   repeat
        [Reference your GUI using plr].Position = UDim2.new(where you want it to be) -- the plr is the player, and to reference the startergui you would need to use plr:WaitForChild("PlayerGui")
    until Out = true
end)

mouse.Button1Down:Connect(function()
    Out = true
end)

Basically it didn’t have much to do with mouseclick at all, I set it up to modify positions as it runs through the aiming and camera process.
In other words, your repositioning idea indeed works all I have to do is hold the GUI in place during reloading.

Looking for a more efficient way to do this if anyone know a better way, if no one knows a better way I’ll recorrect the top solution.

I don’t think that that’s the most efficient way, I think that there are better ways, but I just help people when I can(I’m decent at scripting)

Yeah I 100% appreciate it, this was very helpful but there probably is a better way to do this. Thanks for your help earlier.

If you are trying to lock a 3D vector in a certain position on the screen, use Camera:ScreenPointToRay to do the 2D->3D projection. Then just set the the BillboardGui/ScreenGui 3D position to that projected vector.

1 Like

Honestly look very nice.
Thank you.

1 Like