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

Mouse.Hit and Mouse.Target not working?

Asked by 5 years ago
Edited 5 years ago

Hello, I'm trying to make a demo script, that makes it if you hover over a model named "Noob" a Frame will follow your mouse. I've tried mouse.Hit and Mouse.Target but no matter what the script i'm working with isn't working. Can someone please review it?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Gui = player.PlayerGui:WaitForChild("ScreenGui")

function hover()
    print(mouse.Target.Parent.Name)
    if mouse.Target.Parent.Name == "Noob" then
        Gui.Frame.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
    end
end
mouse.Move:Connect(hover)
0
Can you define which part isn't working? Does it recognize that there is a model named "Noob"? Is it the GUI that isn't moving? Or are your declarations failing? climethestair 1663 — 5y
0
What is the error? HeyItzDanniee 252 — 5y
0
The Gui Isn't moving when I hover over it. As a control, I'm going to test this with a part rq. SBlankthorn 329 — 5y
0
And it still doesn't work. Btw after like 5 seconds the script crashes and says: SBlankthorn 329 — 5y
View all comments (5 more)
0
And it's not crashing anymore cause I moved it to StarterGui SBlankthorn 329 — 5y
0
Is this in a server script? User#20923 0 — 5y
0
Nope. Local SBlankthorn 329 — 5y
0
U can't use local scripts in workspace MaxDev_BE 55 — 5y
0
its not in workspace. Its in StarterGui SBlankthorn 329 — 5y

Answer this question