Mouse cursor textlabel offcenter

I tried making something to overlay with text, but it is displaying off center, and I do not know why. THis is what I’m using:

local Update

script.Parent.MouseEnter:Connect(function()
	local t = game:GetService("TweenService"):Create(script.Parent.Parent.Parent.Parent.Parent.inset.TextLabel, TweenInfo.new(.3), {BackgroundTransparency = .5, TextTransparency = 0})
	t:Play()
	Update = true
end)

script.Parent.MouseLeave:Connect(function()
	local t = game:GetService("TweenService"):Create(script.Parent.Parent.Parent.Parent.Parent.inset.TextLabel, TweenInfo.new(.3), {BackgroundTransparency = 1, TextTransparency = 1})
	t:Play()
	Update = false
end)

local function OffsetToScale(Offset)
	local ViewPortSize = workspace.Camera.ViewportSize
	return ({Offset[1] / ViewPortSize.X * workspace.Value.Value, 0, Offset[2] / ViewPortSize.Y * workspace.Value.Value, 0})
end

local Mouse = game.Players.LocalPlayer:GetMouse()


Mouse.Move:Connect(function()
	print(OffsetToScale({Mouse.X, Mouse.Y}))
	script.Parent.Parent.Parent.Parent.Parent.inset.TextLabel.Position = UDim2.new(OffsetToScale({Mouse.X, Mouse.Y})[1], 0, OffsetToScale({Mouse.X, Mouse.Y})[3], 0) 
end)

(No that is not the path I’m using, I forgot to change it after a test and I’m not bothered to right now.

Thank you

Make sure your anchor point is set correctly. Also, what is workspace.Value?

Hang on do you really need the OffsetToScale function? Cant you just use offset, or am I not seeing something?

Offset will only optimize it from the Studio viewport, scale works universally for the most part

That was a test I forgot to remove. It’s 3am, I should probably sleep instead of code

1 Like