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 |
|
|
| 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
|
  |
| 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 |
|