Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
|
| 01 Oct 2016 10:14 PM |
I can't seem to toggle visibility within this function. I am attempting to use a system where the gui appears when the mouse cursor is aimed at a part of a model that contains an object to distinguish it from other models. If the mouse is not on one of these distinguished models, the gui is expected to disappear, but I am unable to do so.
Here is the code that I have been running
local Player = Game.Players.LocalPlayer local Mouse = Player:GetMouse() local Label = script.Parent.ItemLabel
function MoveGui() if Mouse.Target.Parent.Interface ~= nil then --Checks to see if Interface is part of the model that the mouse is pointing at Label.Position = UDim2.new(0,Mouse.X-50,0,Mouse.Y-15)-- Puts Gui Element just above the cursor Label.Text = Mouse.Target.Parent.NameForInterface.Value -- Sets Gui Text to Value within Model Label.Visible = true else Label.Visible = false end end
Mouse.Move:connect(MoveGui)
|
|
|
| Report Abuse |
|
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
| |
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Oct 2016 02:35 PM |
--Stop capitalizing everything and 'Game' doesnt exist
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local label = script.Parent.ItemLabel
mouse.Move:connect(function() if mouse.Target and mouse.Target.Parent:FindFirstChild('Interface') then label.Position = UDim2.new(0,mouse.X-50,0,mouse.Y-15) label.Text = mouse.Target.Parent.NameForInterface.Value label.Visible = true else label.Visible = false end end)
|
|
|
| Report Abuse |
|
|
DataRoot
|
  |
| Joined: 07 Apr 2016 |
| Total Posts: 586 |
|
|
| 02 Oct 2016 02:36 PM |
| YES YES YES https://www.youtube.com/watch?v=OLuvQoF1o58 |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2016 02:41 PM |
@Time
1. Stop hating on PascalCase, it's just his preference. 2. While I agree it shouldn't be used, Game exists- it's just deprecated. |
|
|
| Report Abuse |
|
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
| |
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
|
| 02 Oct 2016 07:57 PM |
I just tried to use the same script in a regular Roblox game instead of studio. The Gui Does not react to the player's mouse movement. Yes, I am using a local script @time
Any help?
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local label = script.Parent.ItemLabel
mouse.Move:connect(function() if mouse.Target and mouse.Target.Parent:FindFirstChild('NameForInterface') then label.Position = UDim2.new(0,mouse.X-50,0,mouse.Y-15) label.Text = mouse.Target.Parent.NameForInterface.Value label.Visible = true else label.Visible = false end end)
|
|
|
| Report Abuse |
|
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
| |
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
| |
|
Xwing245
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 9 |
|
| |
|