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 » Scripting Helpers
Home Search
 

Yikes. Can't think of the proper algorithm for this.

Previous Thread :: Next Thread 
Ripull is not online. 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
TheGamer101 is not online. TheGamer101
Joined: 14 Feb 2009
Total Posts: 11943
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
sonicdiablo is not online. sonicdiablo
Joined: 05 Feb 2009
Total Posts: 1661
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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