generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: MouseHover Model detection

Previous Thread :: Next Thread 
DrFeynman is not online. 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
eugenevorld is not online. eugenevorld
Joined: 15 Nov 2008
Total Posts: 310
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 is not online. DrFeynman
Joined: 07 Aug 2013
Total Posts: 178
03 Jul 2014 11:30 AM
Returns mouse as a nil
Report Abuse
DrFeynman is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
eugenevorld is not online. eugenevorld
Joined: 15 Nov 2008
Total Posts: 310
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image