local mouse = game.Players.LocalPlayer:GetMouse()
local posX = mouse.x
local posY = mouse.y
while wait() do
script.Parent.mouseframe.Position = UDim2.new(posX,0,posY,0)
end
I want the mouseframe to be at the position of the mouse but it doesn’t seem to work.
I’m pretty sure it’s due to the fact that you’re feeding the Scale values of that UDim2 numbers that are much higher than 1 and 0.
Try moving those to the Offset positions.
UDim2.new(0, posX, 0,posY)
Also you might want to add those mouse positions to the loop so they’re getting updated too
local mouse = game.Players.LocalPlayer:GetMouse()
local posX = mouse.x
local posY = mouse.y
while true do
script.Parent.mouseframe.Position = UDim2.new(0,posX,0,posY)
game:GetService("RunService").Heartbeat:Wait()
end
Edit: Within base of what people said, i have fixed it.
He’s not wanting the hit position, but the position relative to the screen he has that part correct.
If he prefers to use the scale property how ever then he can translate the position to a scaled position
as show here he can just take the Vector2.new(mouse.x, mouse.y) and divide it by the Vector2.new(mouse.ViewSizeX, mouse.ViewSizeY)
and it will give you the position as a scale
I just noticed i learned something new, which is that the player’s mouse has the vector2/udim2 properties, set based on the position of the mouse within the screen/ui interaction. (Badly explained but ok.)
Yessir, I happen to work with ui a lot, lol. But congrats on learning something new, that’s the overall goal here on the dev forums; we’re all learning and improving based on interactions with eachother.