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 » Scripters
Home Search
 

Can you help me with this little problem?

Previous Thread :: Next Thread 
GGLQ is not online. GGLQ
Joined: 31 Mar 2016
Total Posts: 32
27 Jun 2016 02:12 PM
So I made a ball to follow me with this script:
x = game.Workspace.part

while 1 > 0 do
wait(0.1)
x.Position = game.Workspace.Player1.Torso.Position
end
But the problem is...How do I make the ball to follow me after I die?Help me if you can!
Report Abuse
seanbenish is not online. seanbenish
Joined: 31 Jul 2009
Total Posts: 429
27 Jun 2016 02:18 PM
Try this in a serverscript:

game.Players.PlayerAdded:connect(function (p)
local follow = workspace.part:Clone()
follow.Parent = Workspace
follow.Name = p.Name .. " Follower"
p.CharacterAdded:connect(function (c)
while c do
x.Position = c.Torso.Position
wait(.1)
end
end)
end)


public static void main(String[] args) { System.out.println("Oops! Wrong language."); }
Report Abuse
mudkip99 is not online. mudkip99
Joined: 17 Jun 2008
Total Posts: 3362
27 Jun 2016 02:54 PM
This is more a note about your while loop than anything, but if you need an infinite loop that wont crash, just do this:

while true do
... --other code here
wait()
end

Or:

while wait() do
... --other code here
end


1 > 0 is always evaluated as true anyway, so may as well cut out the middleman (also makes it a bit more clear what you're doing), and wait() will yield for the minimum wait time (typically 1/30 seconds, or 0.03333333..., which is normally 1-2 frames depending on your framerate). wait() also evaluates as true when it finishes, so you can replace true with wait() if you want, though I don't care much for that syntax myself.

Neither are really big deals, but one is for clarity, and the other may speed things up if you need an infinite loop but don't want to have (relatively) long breaks in between cycles.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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