DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
|
| 03 Jul 2014 02:35 AM |
I've been coding at a system that when you put you mouse over a model a billboard GUI would appear and says that models name, and I'm honestly not that great at scripting but I've been at it for a while and this is what I was able to come up with.. Have a local script in the starter GUI that ran a anonymous function on a players mouse.hit(), but mouse = a nil value. How would I access the properties of the mouse, and is there a better way of doing this? |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2014 08:41 AM |
If you're trying to get the mouse, try using the 'GetMouse' method of the local player since you are using a local script.
Something like this...
local mouse = game.Players.LocalPlayer:GetMouse()
Wiki page on 'GetMouse' http://wiki.roblox.com/index.php?title=GetMouse_(Method)/Player |
|
|
| Report Abuse |
|
|
DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
| |
|
DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
|
| 03 Jul 2014 03:35 PM |
Nvm no it doesn't this is the code I came up with, still needs a lot of thinks but here:
(Localscript in startergui)
local mouse = game.Players.LocalPlayer:GetMouse()
function showdata() if mouse.Target.Parent.ClassName == "Model" then print(mouse.Target.Parent.Name) end end
-- I don't know how to call this function |
|
|
| Report Abuse |
|
|
DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
|
| 03 Jul 2014 03:39 PM |
Example of what I'm talking about
http://www.roblox.com/Fading-Embers-place?id=102210997 |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 03 Jul 2014 03:46 PM |
local mouse = game.Players.LocalPlayer:GetMouse()
function showdata() if mouse ~= nil then if mouse.Target.Parent.className == "Model" then print(mouse.Target.Parent.Name) end end end mouse.Move:connect(showdata) |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 03 Jul 2014 03:48 PM |
Next, the billboard gui would have to go in the players playergui for it to be local..
Just set the billboardgui.Adornee to the mouse.Target for it to display over the mouse's target
Set the billboard gui's text to be the mouse.Target.Parent.Name for the name to display |
|
|
| Report Abuse |
|
|
DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
|
| 03 Jul 2014 03:58 PM |
| Thank you so much, Anything I can do to repay? |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 03 Jul 2014 04:01 PM |
It's fine, you came to a place where help is free.
Btw, i made a mistake!
if mouse ~= nil then
Change this line to
if mouse.Target ~= nil then
This is so it doesn't error when u hover over the sky. |
|
|
| Report Abuse |
|
|
DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
|
| 03 Jul 2014 04:41 PM |
local mouse = game.Players.LocalPlayer:GetMouse()
function showdata() if mouse.Target ~= nil then if mouse.Target.Parent.className == "Model" then print("datamodel working") script.Datagui:Clone() end end end
mouse.Move:connect(showdata)
How would I clone a GUI into playergui, so when I hover over something it pops up with a gui at the mouse? |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 03 Jul 2014 04:44 PM |
Oh, at the mouse? so you don't want billboard gui's.
In that case;
local mouse = game.Players.LocalPlayer:GetMouse()
function showdata() if mouse.Target ~= nil then if mouse.Target.Parent.className == "Model" then print("datamodel working") data = script.Datagui:Clone() data.Parent = game.Players.LocalPlayer.PlayerGui end end end
mouse.Move:connect(showdata) |
|
|
| Report Abuse |
|
|
DrFeynman
|
  |
| Joined: 07 Aug 2013 |
| Total Posts: 178 |
|
|
| 03 Jul 2014 04:54 PM |
And to keep the cloning at a minimum? This is what I'm trying to replicate (sorry)
http://www.roblox.com/Fading-Embers-place?id=102210997 |
|
|
| Report Abuse |
|
|
samy22
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 2181 |
|
|
| 03 Jul 2014 04:55 PM |
local mouse = game.Players.LocalPlayer:GetMouse()
function showdata() if mouse.Target ~= nil then if mouse.Target.Parent.className == "Model" then print("datamodel working") if game.Players.LocalPlayer.PlayerGui:findFirstChild("Datagui") == nil then data = script.Datagui:Clone() data.Parent = game.Players.LocalPlayer.PlayerGui end end end end
mouse.Move:connect(showdata) |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2014 04:37 AM |
So you want some form of tooltip that appears whenever you hover over an object. If you are trying to replicate the Gui in Fading embers, it won't be that easy since there are probably more than one script keeping track of things. Things such as the name of the object and some characteristics. If you are just trying to replicate the tooltip that comes up, it shouldn't be too hard. You just check which model the part belongs to with this function...
function GetParentModel(instance) if instance.Parent ~= workspace then GetParentModel(instance) elseif instance.ClassName == "Model" then return instance end end
Although it checks for the highest parent so it might be inappropriate. Rename the model to what you want to show up on the tooltip and just create a TextLabel beside the mouse with the model's name. |
|
|
| Report Abuse |
|
|