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

This is weird-clicking raises mouse position?

I have a simple LocalScript that-put simply-puts the TextLabel to the side of your mouse if you're hovering over a specific part. What's weird, though, is that the textlabel/mouse Y position moves by about 36 offset pixels up when mouseclicking. It's very odd and awkward/glitchy. That isn't supposed to happen.. right?

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
while wait() do
	if mouse.Target ~= nil then
		if mouse.Target.Name == "TestyTest" then
			script.Parent.TextLabel.Position = UDim2.new(0,mouse.X-30,0,mouse.Y-86)
			script.Parent.TextLabel.Text = "TestyTest"
			script.Parent.TextLabel.Visible = true
		else
			script.Parent.TextLabel.Visible = false
			script.Parent.TextLabel.Text = "Label"
		end
	end
end

Sorry about the lag in the GIF: http://i.imgur.com/k1DmkiL.gifv

1 answer

✓ Accepted answer

Nope, that ain't supposed to happen. Though I do not know what the direct problem is, I do have a piece of advice. Try not using while wait() do, it will clog up your game and possibly make it more laggy if there are to many of these while wait() do loops. In this case, I would do this:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
mouse.Move:connect(function()
    if mouse.Target ~= nil then
        if mouse.Target.Name == "TestyTest" then
            script.Parent.TextLabel.Position = UDim2.new(0,mouse.X-30,0,mouse.Y-86)
            script.Parent.TextLabel.Text = "TestyTest"
            script.Parent.TextLabel.Visible = true
        else
            script.Parent.TextLabel.Visible = false
            script.Parent.TextLabel.Text = "Label"
        end
    end
end)

This is much more efficient and will cause less strain on the client in the long run. Who knows, it might also solve your problem.

2 comments

0

It actually does-very odd. And it doesn't stutter anymore.

0

I blame Roblox new transparent menu bar, they moved it to the top. It was on the bottom before..

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