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
 

Re: Magnitude help D:

Previous Thread :: Next Thread 
AboveAwesome is not online. AboveAwesome
Joined: 24 Jul 2010
Total Posts: 1823
31 Mar 2012 02:21 PM
I'm working on an interactive dialog system with GUIs, and I have a script in an NPC's torso that detects the magnitude of players' torsos and does stoof accordingly. Everything works fine ingame, until about after 5 minutes, when the script suddenly breaks for no apparent reason. I've used a few scripts using magnitude for doors etc. before, and this would always happen. Is there any way to fix this?

Here's my script.

while wait() do
p = game.Players:GetChildren()
for i=1, #p do
if (p[i].Character.Torso.Position - script.Parent.Position).magnitude <= 5 then
if p[i].PlayerGui:FindFirstChild("Interact") == nil then
local igui = script.Parent.Interact:Clone()
igui.Parent = p[i].PlayerGui
igui.Main.Owner.Value = script.Parent
igui.Main.Enter.Disabled = false
igui.Main.Leave.Disabled = false
end
else
wait()
end
end
end
Report Abuse
AboveAwesome is not online. AboveAwesome
Joined: 24 Jul 2010
Total Posts: 1823
31 Mar 2012 02:33 PM
Anyone?
Report Abuse
silverfire17 is not online. silverfire17
Joined: 28 Jan 2012
Total Posts: 42
31 Mar 2012 02:34 PM
Maybe it is breaking because the Torso can't be found?
Report Abuse
AboveAwesome is not online. AboveAwesome
Joined: 24 Jul 2010
Total Posts: 1823
31 Mar 2012 02:38 PM
I don't think so, but I'll try that.

Got a siggy :D
○ Interpret that any way you want. ○
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
31 Mar 2012 02:40 PM
Sometimes, players' characters are nil, which means you can't index 'Torso' from the character. Either check to see if the player has a character, or you can surround the entire thing with pcall.
Report Abuse
AboveAwesome is not online. AboveAwesome
Joined: 24 Jul 2010
Total Posts: 1823
31 Mar 2012 02:45 PM
Ah, good idea. Thanks, Firefox.

○ Interpret that any way you want. ○
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