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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: MouseHoverEnter is not a valid member of Part?

Previous Thread :: Next Thread 
DeGames is online. DeGames
Joined: 08 Sep 2012
Total Posts: 1028
07 Aug 2015 07:27 PM
Hi I'm a noobie at Lua and I'm trying to make a basic script that will create a GUI when the brick is moused over.

Here's what I have so far


player = game.Players
SG = Instance.new("ScreenGui")
T = Instance.new("TextLabel")
SG.Parent = player:FindFirstChild("PlayerGui")
T.Parent= SG

function enter()
SG.Textlabel.Text=("Wood")
end


function leave()
SG.Textlabel.Text=("")
end

script.Parent.MouseHoverEnter:connect(enter)
script.Parent.MouseHoverLeave:connect(leave)

On the Outpout it is giving me "MouseHoverEnter is not a valid member of Part"

Report Abuse
lomo0987 is not online. lomo0987
Joined: 31 May 2008
Total Posts: 2461
07 Aug 2015 07:32 PM
MouseHoverEnter is for ClickDetectors. Place a click detector and string it to that. :D
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Aug 2015 07:38 PM
"player = game.Players"

just saying, that's only going to get the Players service, not a player

if you want this to work, you need to use the player parameter that is provided with .MouseHoverEnter and .MouseHoverLeave. (this won't work with FilteringEnabled, but i assume you're not using it anyway)

local part = script.Parent
local cd = part:WaitForChild('ClickDetector')

cd.MouseHoverEnter:connect(function(player)
local SG = Instance.new("ScreenGui")
local T = Instance.new("TextLabel")
local SG.Parent = player:FindFirstChild("PlayerGui")
local T.Parent= SG

T.Text = "Wood"
end)

cd.MouseHoverLeave:connect(function(player)
local sg = player:FindFirstChild("ScreenGui")
local t = sg:FindFirstChild("TextLabel")

t.Text = ""
end)

Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Aug 2015 07:39 PM
cd.MouseHoverLeave:connect(function(player)
local sg = player:FindFirstChild("ScreenGui")
local t = sg:FindFirstChild("TextLabel")

if sg and t then
t.Text = ""
end
end)

just to make sure the screengui and textlabel exist
Report Abuse
DeGames is online. DeGames
Joined: 08 Sep 2012
Total Posts: 1028
07 Aug 2015 07:48 PM
A bit confused.
This is what I did.

player = game.Players
SG = Instance.new("ScreenGui")
T = Instance.new("TextLabel")
D = Instance.new("ClickDetector")
SG.Parent = player:FindFirstChild("PlayerGui")
T.Parent= SG
D.Parent= game.Workspace.Wood
function enter()

SG.Textlabel.Text=("Rock")
end


function leave()
SG.Textlabel.Text=("")
end

script.Parent.MouseHoverEnter:connect(enter)
script.Parent.MouseHoverLeave:connect(leave)
Report Abuse
DeGames is online. DeGames
Joined: 08 Sep 2012
Total Posts: 1028
07 Aug 2015 07:51 PM
Oh sorry instawin, didn't see your post. I'll take a look.
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Aug 2015 07:54 PM
oh and i forgot, because you create the textlabel with Instance.new(), you'll need to give the new textlabel size and a position
Report Abuse
DeGames is online. DeGames
Joined: 08 Sep 2012
Total Posts: 1028
07 Aug 2015 08:03 PM
Oh yeah, that makes sense.

The modified version you made, I'm unclear about.

What does

cd.MouseHoverLeave:connect(function(player)

do?

I'm assuming its the same thing as
script.Parent.MouseHoverEnter:connect(enter)
script.Parent.MouseHoverLeave:connect(leave)

but with the player parameter thing.

So I guess the real question is what is player parameter?
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
07 Aug 2015 08:08 PM
"What does

cd.MouseHoverLeave:connect(function(player)

end)
do?"

it's an anonymous function, they're mainly used here as short-hand for connecting functions to your desired event.

http://wiki.roblox.com/index.php?title=Anonymous_function

as for the player parameter, it is the player that hovered over your click detector
http://wiki.roblox.com/index.php?title=MouseHoverEnter

Report Abuse
lomo0987 is not online. lomo0987
Joined: 31 May 2008
Total Posts: 2461
07 Aug 2015 08:08 PM
Degames, the

:connect(fucntion()
--code
end)

is still the same as using
function bleh()
--code
end

:connect(bleh)

but the first just moves the :connect() to the function itself. it's not better to do it that way it's better to do it the way you are currently doing.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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