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: Script problem

Previous Thread :: Next Thread 
NightPyro is not online. NightPyro
Joined: 22 Apr 2012
Total Posts: 183
09 Nov 2012 02:02 PM
distance = 4

while true do
wait(.1)
for i,v in pairs(game.Players:GetChildren()) do
human = v.Character:FindFirstChild("Torso")
if human ~= nil and (game.Workspace.Door1.Position - human.Position).magnitude <= distance then
if (game.Workspace.Door1.Position - human.Position).magnitude <= distance then

v.PlayerGui.MainHUD.Buy.Dooor1.Visible = true--I think it would be v to access the player defined in the pairs thingy...
if (game.Workspace.Door1.Position - human.Position).magnitude >= distance then
v.PlayerGui.MainHUD.Buy.Dooor1.Visible = false
end
end end

end

end


I can make the gui pop up on the screen, but i can't figure out how to make it go away.. When you walk away from the brick.
Report Abuse
NightPyro is not online. NightPyro
Joined: 22 Apr 2012
Total Posts: 183
09 Nov 2012 02:07 PM
...?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Nov 2012 02:10 PM
You have an if statement checking for magnitude.
Simply add an else block to that statement that sets the GUI visibility to false
Report Abuse
NightPyro is not online. NightPyro
Joined: 22 Apr 2012
Total Posts: 183
09 Nov 2012 02:16 PM
I already tried that.. It doesn't work..
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Nov 2012 02:19 PM
This will be hard to explain on my phone. Otherwise I'd just give you the script. Here goes.

Your second if statement that checks magnitude? Scrap it.
Use an else statement for that instead.
Report Abuse
NightPyro is not online. NightPyro
Joined: 22 Apr 2012
Total Posts: 183
09 Nov 2012 02:29 PM
distance = 4

while true do
wait(.1)
for i,v in pairs(game.Players:GetChildren()) do
human = v.Character:FindFirstChild("Torso")
if human ~= nil and (game.Workspace.Door1.Position - human.Position).magnitude <= distance then
v.PlayerGui.MainHUD.Buy.Dooor1.Visible = true--I think it would be v to access the player defined in the pairs thingy...
else (game.Workspace.Door1.Position - human.Position).magnitude <= distance then
wait(.1)
v.PlayerGui.MainHUD.Buy.Dooor1.Visible = false

end

end end

end
Is this what you mean? I have an error on line 9.. but is this what you mean?

Note: Line 9 error is abotut he "<="
Report Abuse
crouton04 is not online. crouton04
Joined: 07 Jul 2010
Total Posts: 4459
09 Nov 2012 02:57 PM
distance = 4

while true do
wait(.1)
for i,v in pairs(game.Players:GetChildren()) do
human = v.Character:FindFirstChild("Torso")
if human ~= nil and (game.Workspace.Door1.Position - human.Position).magnitude <= distance then
v.PlayerGui.MainHUD.Buy.Dooor1.Visible = true--I think it would be v to access the player defined in the pairs thingy...
else (game.Workspace.Door1.Position - human.Position).magnitude = distance
wait(.1)
v.PlayerGui.MainHUD.Buy.Dooor1.Visible = false

end

end end


--- this should work..
Report Abuse
NightPyro is not online. NightPyro
Joined: 22 Apr 2012
Total Posts: 183
09 Nov 2012 05:09 PM
Uhmm, i still can't figure it out.. Sorry.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Nov 2012 05:32 PM
Get rid of the condition in the else block. Set the visibility to false in the else block. Also get rid of the wait in the else block.
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