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 » Scripters
Home Search
 

Re: Mouse.Target

Previous Thread :: Next Thread 
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 09:09 PM
This doesnt make any sense to me because when I use this script.

local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player:GetMouse()
while true do
wait()
print(mouse.Target)

Output: nil , nil , nil , nil , nil , Baseplate , Baseplate , Baseplate , Baseplate, Door , Door , Door , Door , Door etc... So its obviously picking up a target. But when I use this script.

local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player:GetMouse()
if mouse.Target == "Door" then
print("Door")
end

Or this one.

local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player:GetMouse()
if mouse.Target.Name == ("Door") then
print("Door")
end

Or this one

local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player:GetMouse()
if mouse.Target == workspace.Door then
print("Door")
end

None of them work. Does anyone have the source of their possible solution?

Report Abuse
LOL45327 is not online. LOL45327
Joined: 30 Mar 2013
Total Posts: 110
15 Nov 2015 09:13 PM
Um no sorry i wish i could help but i know nothing about scripting
😞
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 09:13 PM
Oh yeah and I also tried:

local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player:GetMouse()
if mouse.Target == workspace.Door.Position then
print("Door")
end
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 09:22 PM
ß
Report Abuse
goro7 is not online. goro7
Joined: 01 Jul 2009
Total Posts: 735
15 Nov 2015 09:26 PM
Try this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Changed:connect(function()
if mouse.Target ~= nil then
if mouse.Target.Name == "Door" then
print("WE GOT A DOOR!")
end
end
end)
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 09:29 PM
No that didnt work, If someone knows how to do this, please post the link to your source.
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
15 Nov 2015 09:39 PM
Is "Door" a model, or a part named "Door"?
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
15 Nov 2015 09:40 PM
Idk that's all I got, it should work.
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 09:41 PM
Its a part.
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 09:45 PM
It doesnt work.
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
15 Nov 2015 09:47 PM
try adding print(mouse.Target) above the if statement to check what it's getting, if you haven't already.
Report Abuse
goro7 is not online. goro7
Joined: 01 Jul 2009
Total Posts: 735
15 Nov 2015 09:48 PM
Try this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Move:connect(function()
if mouse.Target ~= nil then
if mouse.Target.Name == "Door" then
print("WE GOT A DOOR!")
end
end
end)
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 10:50 PM
Didnt work
Report Abuse
alphaboy299 is not online. alphaboy299
Joined: 15 Jun 2013
Total Posts: 1496
15 Nov 2015 10:51 PM
local player = game.Players:WaitForChild("LocalPlayer")
local mouse = player:GetMouse()
if mouse.Target == "Door" then
print("Door")
else
return
end
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 10:55 PM
No
Report Abuse
LOL45327 is not online. LOL45327
Joined: 30 Mar 2013
Total Posts: 110
15 Nov 2015 10:59 PM
Sorry dude
Report Abuse
alphaboy299 is not online. alphaboy299
Joined: 15 Jun 2013
Total Posts: 1496
15 Nov 2015 11:04 PM
Ugh... this is why I hate this forum.If I have to answer anything I have to use my brain.

Anyway have you tried looping it in any way?How about this-

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

function check()
if mouse.Target == workspace.Door then
print("Door")
else
return check()
end
end

check()

Report Abuse
LOL45327 is not online. LOL45327
Joined: 30 Mar 2013
Total Posts: 110
15 Nov 2015 11:10 PM
That might work
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 11:32 PM
none of this worked
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
15 Nov 2015 11:35 PM
Your problem is the :WaitForChild("LocalPlayer")

LocalPlayer is an Object property, its not a Child of the Players service.

Just use game.Players.LocalPlayer
LocalScripts don't actually run until that property gets set.
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
15 Nov 2015 11:55 PM
Oh, it wasnt even in a local script ... v.v and if i try that wont it just give me an error because im trying to index it?
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
16 Nov 2015 12:03 AM
You can't even use GetMouse in a normal script.
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
16 Nov 2015 12:06 AM
Well I tried this two different ways.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
if mouse.Target == workspace.BasePlate then
print("Baseplate")
end

And

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
if mouse.Target == workspace.BasePlate then
print("Baseplate")
end


Even with ("Baseplate") instead of workspace.Baseplate
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
16 Nov 2015 12:08 AM
In a LocalScript?
The thing is, when the script runs, it will check immediately what your target is, its not going to continuously look and check it.

Try this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local door = workspace:WaitForChild("Door")

while wait() do
local target = mouse.Target
if target == door then
print(door)
end
end
Report Abuse
LOL45327 is not online. LOL45327
Joined: 30 Mar 2013
Total Posts: 110
16 Nov 2015 12:09 AM
So did it work
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