You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
i want to make a frame that moves with the player’s camera
What is the issue? Include screenshots / videos if possible!
i don’t know how
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
not yet, if the solutions here don’t work i will use the developer hub
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
I don’t really understand what you want. Objects parented to screengui automatically stay on the same position on the screen, so they kind of always follow the camera, because the screen shows what the “camera” sees.
Do you want a gui that is where the mouse is on the screen? Or do you want to make a 2D gui object world where you move the camera (not the roblox camera object) by moving a frame that is used as the world?
local UserInputService = game:GetSetvice("UserInputService")
local GuiService = game:GetService("GuiService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local plr = Players.LocalPlayer
-- if you parent this to the gui object, you can just do local guiObj = script.Parent.
-- If you have the script elsewhere and the gui somewhere in playergui, you should use `WaitForChild` when referencing the gui object.
local guiObj = -- reference here
local guiInset = GuiService:GetGuiInset().Y
RunService.RenderStepped:Connect(function()
local mouseLocation = UserInputService:GetMouseLocation()
guiObj.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y+guiInset)
end)
If the screen gui which’s descendant the guiObject is has `IgnoreGuiInset set to true, the guiInset is useless.