|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 15 Nov 2015 09:39 PM |
| Is "Door" a model, or a part named "Door"? |
|
|
| Report Abuse |
|
|
|
| 15 Nov 2015 09:40 PM |
| Idk that's all I got, it should work. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
| |
|
|
| 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 |
|
|
| |
|
LOL45327
|
  |
| Joined: 30 Mar 2013 |
| Total Posts: 110 |
|
| |
|
|
| 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
|
  |
| Joined: 30 Mar 2013 |
| Total Posts: 110 |
|
| |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 16 Nov 2015 12:03 AM |
| You can't even use GetMouse in a normal script. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 30 Mar 2013 |
| Total Posts: 110 |
|
| |
|