Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui Not Showing Up Where Mouse Is On Click?

alright so in my script i have it where when a player clicks one gui it makes another visible or not visible which works fine but im wanting it to set the top left corner of the gui to where the mouse was at the time of the click which does not work ive had it going into the hundreds with position and what ive got now is the closest ive got to it working

Script:

local MainGui = script.Parent.Parent.Parent.MainFrame

local PlayerOptions = MainGui.PlayerOptions

local Player = game.Players.LocalPlayer

local Mouse = Player:GetMouse()

script.Parent.MouseButton2Click:Connect(function()

PlayerOptions.Position = UDim2.new(0, Mouse.X/5.5, 0, Mouse.Y/5.5) -- the issue here

PlayerOptions.Visible = not PlayerOptions.Visible

end)

3 comments

0

You're looking for Mouse.[RelativeAxis]/Mouse.ViewSize[RelativeAxis]; Mouse.X/Mouse.ViewSizeX.

0

alright thanks man ill try this once i get home ive seen this somewhere before but forgot about it

0

didnt work out stays in the top left corner of the frame its in

1 answer

✓ Accepted answer

If you want the top left of your gui to move to where your Mouse is then you'll want to make the AnchorPoint of the gui frame to 0, 0 and then you'll just want to do

Frame.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)

1 comment

0

didnt work exactly how i wanted it to but i can get it to work form there thanks a lot

This discussion is preserved as it was. New answers, comments, and votes are closed.