Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gui Not Showing Up Where Mouse Is On Click?

Asked by
Donut792 216 Moderation Voter
5 years ago

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)
0
You're looking for Mouse.[RelativeAxis]/Mouse.ViewSize[RelativeAxis]; Mouse.X/Mouse.ViewSizeX. Ziffixture 6913 — 5y
0
alright thanks man ill try this once i get home ive seen this somewhere before but forgot about it Donut792 216 — 5y
0
didnt work out stays in the top left corner of the frame its in Donut792 216 — 5y

1 answer

Log in to vote
1
Answered by
Kymaraaa 116
5 years ago
Edited 5 years ago

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)
0
didnt work exactly how i wanted it to but i can get it to work form there thanks a lot Donut792 216 — 5y
Ad

Answer this question