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 » Game Design
Home Search
 

Re: mouse.Target HELP

Previous Thread :: Next Thread 
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 09:32 PM
How would I make it so that when the mouse goes over a block a little gui pops up. I made this but it doesn't work.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

if mouse.Target == script.parent then
local gui = Instance.new("ScreenGui", player.PlayerGui)
local txt = Instance.new("TextLabel", gui)
txt.Text = "Testing"
txt.BackgroundColor = Color3.new(0,0,0)
txt.BackgroundTransparency = .5
txt.TextColor = Color3.new(255,255,255)
end
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
21 Aug 2015 09:38 PM
I believe it needs to be in a local script in the player not a normal script in the brick,

I am a noob so don't listen to me as a god and I may be wrong
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 09:40 PM
Hmm, I don't think so as the wiki says "The object that the mouse is pointing to." But then again I'm asking here because I don't understand the wiki.
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
21 Aug 2015 09:43 PM
Would you mind trying altering the script and putting it in the starter pack?

I've done it before with a keypressed script and it needed to be in the player and in a local script because it was calling upon a local function (the players mouse over)
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 09:46 PM
I moved it to Starterplayer like you said and did this, but it still doesn't work.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

if mouse.Target == workspace.Part then
--local gui = Instance.new("ScreenGui", player.PlayerGui)
--local txt = Instance.new("TextLabel", gui)
--txt.Text = "Testing"
--txt.BackgroundColor = Color3.new(0,0,0)
--txt.BackgroundTransparency = .5
--txt.TextColor = Color3.new(255,255,255)
print('found')
end
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
21 Aug 2015 09:48 PM


local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.Changed:connect(function(p)
if p == "Target" then --change this to ur brick name
print("hi")
end
end)

Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 09:55 PM
Nope and it's in a local script in StarterPlayer.
Report Abuse
8BitDeveloping is not online. 8BitDeveloping
Joined: 09 Aug 2011
Total Posts: 1472
21 Aug 2015 10:00 PM
StarterPack, not starterPlayer.


potato
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
21 Aug 2015 10:00 PM
Even with adding the changed event?
What does output say?

Nvm your first if statement should work

That's in a gui do:
if mouse.Target == MyBrick then
MyBrick.BrickColor = BrickColor.Red()
else
MyBrick.BrickColor - BrickColor.Green()
end
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 10:09 PM
What do you mean in a gui??

The part turns Green but doesn't change to red when my mouse is over it nor when I click it.
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
21 Aug 2015 10:19 PM
Don't mind he in a gui statement I'm not all here atm lol

What does output say if anything? It's a local script?

Try having it print mouse.Target upon changed
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 10:21 PM
Output says nothing, and yes it's local script, I tried to make it print mouse.Target upon changed but nothing comes through the output.
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
21 Aug 2015 10:23 PM
Is it also to be noted that i'm using a custom mouse Icon?? Would that affect anything and, I tried the mouse changed thing again and the only time it printed was when (I'm assuming) the icon was changed to my custom one.
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
21 Aug 2015 10:45 PM
I doubt the mouse icon has anything to do with it, But it could be and I'm a noob

Try changing local player = game.localplayer to player = script.Parent.Parent depending on where local script is located
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 09:13 AM
Ugh that didn't work either. And output still says nothing. :((
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 10:06 AM
bump
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 02:30 PM
Bumppp
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
22 Aug 2015 02:31 PM
Post whole script again
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 04:28 PM
This one?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

if mouse.Target == script.parent then
local gui = Instance.new("ScreenGui", player.PlayerGui)
local txt = Instance.new("TextLabel", gui)
txt.Text = "Testing"
txt.BackgroundColor = Color3.new(0,0,0)
txt.BackgroundTransparency = .5
txt.TextColor = Color3.new(255,255,255)
end
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
22 Aug 2015 04:32 PM
No the local script located in starter pack we worked on
Report Abuse
Ortron is not online. Ortron
Joined: 19 Jul 2013
Total Posts: 1297
22 Aug 2015 04:51 PM
If it's in starter pack then the parent is PlayerGui which will never be hit by the mouse.
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
22 Aug 2015 04:56 PM
A mouse can dream but let him post the script so we can actually see the issue
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 08:28 PM
Wait, so it has to be a script in the part??
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 08:36 PM
Here is our script, so far, it only prints once which is when i'm assuming the icon is changed.

local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.Changed:connect(function(p)
print('mouse changed')
end)
Report Abuse
ThisUserSecret is not online. ThisUserSecret
Joined: 29 Sep 2012
Total Posts: 1094
22 Aug 2015 08:47 PM
NVM I feel dumb, I just put it into a loop and it worked. Thank you for your help gnome!!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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