Ripull
|
  |
| Joined: 21 Jul 2008 |
| Total Posts: 14249 |
|
|
| 25 Apr 2014 07:10 PM |
Interaction method, when you mouse over something, a function is fired. Having trouble with the mouse being nil.
Problem: Players.Player1.PlayerGui.LocalPlayerScripts.Interaction:276: attempt to index field 'Target' (a nil value)
Problematic code section:
--mouse and functions already defined in another part of the script. --MouseOver Interact item
local Interact = pcall(mouse.Target.Changed:connect(function() --Problem here. if mouse.Target then if mouse.Target.Name == "Prop" then HelpBarOpen("Press 'E' to morph into this prop.") else HelpBarClose() end if mouse.Target.Parent:FindFirstChild("Active") then HelpBarOpen("Press 'E' to interact with this" ..mouse.Target.Parent.Name".") elseif mouse.Target.Parent.Parent:FindFirstChild("Active") then HelpBarOpen("Press 'E' to interact with this" ..mouse.Target.Parent.Parent.Name".") else HelpBarClose() end end end))
|
|
|
| Report Abuse |
|
|
|
| 25 Apr 2014 07:27 PM |
Changed doesn't work quite like that. It is a method of the object, not the property. So instead of mouse.Target.Changed it would be mouse.Changed. It returns the property that was changed.
http://wiki.roblox.com/index.php?title=Property |
|
|
| Report Abuse |
|
|
|
| 25 Apr 2014 08:32 PM |
| An infinite loop with a small wait time might be better than using a Changed event on the mouse, since the event will be fired everytimes the mouse moves by a pixel,if I remember correctly. |
|
|
| Report Abuse |
|
|
Ripull
|
  |
| Joined: 21 Jul 2008 |
| Total Posts: 14249 |
|
|
| 25 Apr 2014 08:34 PM |
| I used mouse.Move in the end. Had to debounce it because it takes so much darn processor power for something so simple. |
|
|
| Report Abuse |
|
|