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.
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
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 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)
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.
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.
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.