Sylverant
|
  |
| Joined: 11 Aug 2014 |
| Total Posts: 30 |
|
|
| 30 Jan 2015 01:13 PM |
Now, I haven't been on Roblox for some time now, so my scripting skills have degraded to mediocre at best. I'm expecting the following script to print something when a player's mouse is moved over the named part; however, nothing happens. No error messages, no "printing", nothing. Why is this?
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.Move:connect(function() if Mouse.Target == game.Workspace["Part45"] then print(Mouse.Target) else end end)
|
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 01:38 PM |
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.Move:connect(function() local target = Mouse.Target if target == workspace.Part45 then print(target.Name) end end)
Should be a LocalScript |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
|
| 30 Jan 2015 01:39 PM |
| ^ is exactly the same, btw add more prints and breakpoints |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 01:44 PM |
| @parkiet I know, I just cleaned it up a bit and said make it local. |
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
|
| 30 Jan 2015 01:46 PM |
| try using the changed event instead of move. then make it take an argument. next put a condition if the changed property is the target. |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 01:48 PM |
Here's a debug version:
print("Active") local Mouse = game.Players.LocalPlayer:GetMouse() print("Mouse Set")
Mouse.Move:connect(function() print("Moved") local target = Mouse.Target print("target Set") if target == workspace.Part45 then print("If statement true") print(target.Name) print = function() end --So this isn't drowned out by move end print("If statement ended") end) print("Mouse Move event set") |
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
|
| 30 Jan 2015 01:53 PM |
| Dude, I know printing the mouse's target doesn't require that much code. dang... |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 01:54 PM |
@Rob
That's a debug version, printing will help us to learn what happened. |
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
| |
|
|
| 30 Jan 2015 02:00 PM |
While I'm at it...
print("Active") local Mouse = game.Players.LocalPlayer:GetMouse() print("Mouse Set", Mouse)
Mouse.Move:connect(function() print("Moved") local target = Mouse.Target print("target Set", target, workspace.Part45) if target == workspace.Part45 then print("If statement true") print(target.Name) print = function() end --So this isn't drowned out by move end print("If statement ended") end) print("Mouse Move event set")
Will let us monitor the variables... |
|
|
| Report Abuse |
|
|