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

This is weird-clicking raises mouse position?

Asked by
unmiss 337 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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.

0
It actually does-very odd. And it doesn't stutter anymore. unmiss 337 — 8y
0
I blame Roblox new transparent menu bar, they moved it to the top. It was on the bottom before.. Nickoakz 231 — 8y
Ad

Answer this question