I'm trying to make a screengui show up when your mouse hovers over a brick, which I have actually got to work. My problem though comes when I try to set it to work at a distance of 10 studs or less.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() if (torso.Position - game.Workspace.Part1.Position).magnitude <11 then mouse.Move:connect(function() if mouse.Target and mouse.Target == game.Workspace.Part1 then player.PlayerGui.SpecialHoverGUI.Frame.Visible = true else player.PlayerGui.SpecialHoverGUI.Frame.Visible = false end end)
I can't for the life of me understand what's going wrong. (I am a novice scripter which would probably explain a lot). Please help!
Nice try. The only thing I see wrong, is that you need to move your first if statement down a bit, since it doesn't constantly check if you're within range!
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.Move:connect(function() if mouse.Target and mouse.Target == game.Workspace.Part1 and (player.Character.Torso.Position - game.Workspace.Part1.Position).magnitude <11 then -- Move the if statement down here, so whenever the mouse moves, it can check the range! player.PlayerGui.SpecialHoverGUI.Frame.Visible = true else player.PlayerGui.SpecialHoverGUI.Frame.Visible = false end end)