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

How do you properly scale an image to the mouses position?

I'm new to the scaling property when it comes to;

UDim2.new(1,0,1,0)

So I'm having a difficult time thinking of how I'd scale an image to the players mouse. I've tried stuff like this;

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local image = script.Parent:WaitForChild("ImageLabel")

image.Position = UDim2.new(mouse.X,0,mouse.Y,0)

It's a bit frustrating, because I keep getting 100 or 200 in the properties of the position just because of the way Mouse.X works.

So if anyone's out there that understands what I mean and would like to give me a solution to my problems I'm all ears.

I know you have to use math to determine the scaling, I just don't understand what type of method to use

2 answers

Hi, Acerion. In this script You donot need math.. Instead of image.Position = UDim2.new(mouse.X,0,mouse.Y,0) Try, image.Position = UDim2.new(0,mouse.X,0,mouse.Y) This should work for what you are trying to do..


local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local image = script.Parent:WaitForChild("ImageLabel")
while wait() do
image.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end

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