|
| 12 Jul 2014 11:55 PM |
repeat wait() until game.Players.LocalPlayer.Character plr = game.Players.LocalPlayer chr = plr.Character Frame = script.Parent o = false
game.Players.ChildAdded:connect(function(C) z = Instance.new("Frame") z.Parent = Frame z.Size = UDim2.new(0.1, 0, 0.1, 0) z.Name = C.Name while wait() do repeat wait() until C.Character f = (chr.Torso.Position - C.Character.Torso.Position) A = f.X B = f.Z z.Position = UDim2.new(A/100,0,B/100,0) end end)
It mostly works. When Player2 is added, it works, but when Player3 is added, it doesn't work. Any ideas?
|
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 12:40 AM |
repeat wait() until game.Players.LocalPlayer.Character plr = game.Players.LocalPlayer chr = plr.Character Frame = script.Parent o = false
game.Players.ChildAdded:connect(function(C) z = Instance.new("Frame") z.Parent = Frame z.Size = UDim2.new(0.1, 0, 0.1, 0) z.Name = C.Name w = coroutine.create(function() while wait() do repeat wait() until C.Character f = (chr.Torso.Position - C.Character.Torso.Position) A = f.X B = f.Z z.Position = UDim2.new(A/100,0,B/100,0) end end) coroutine.resume(w) end) |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 12:41 AM |
| The coroutine didn't fix it... any other ideas? |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 13 Jul 2014 12:42 AM |
| Do you have any kind of output in the server window? In the client window? |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 12:45 AM |
| No, what it does is weird. So it works when Player2 is added. But when Player3 is added, the Player3 is teleported to the Player2 gui and then the Player2 gui is frozen and the Player3 gui is kinda glitchy. |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 13 Jul 2014 12:47 AM |
I don't actually know if this makes a difference, but it's bugging me since you're yielding a tick twice when you should be once.
the repeat wait() until C.Charcter should probably go above your while loop. Let me look again... Nothing obvious is sticking out still though. The coroutine should be completely unnecessary as well. Events multithread on their own. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 12:49 AM |
| Well later I am going to add it into another script. So I do need it. |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 13 Jul 2014 12:58 AM |
| Care to share a model of this? It seems like I would just need the little bit of UI to test it out and tweak some things. I'm more of a hands on debugger with print and such anyway... |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 01:09 AM |
| Well it is not hard to recreate... just a ScreenGui with a Frame in it. |
|
|
| Report Abuse |
|
|
| |
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 13 Jul 2014 01:17 AM |
| Doing some testing now, I'll check back in with you in a minute. |
|
|
| Report Abuse |
|
|
aboy5643
|
  |
| Joined: 08 Oct 2010 |
| Total Posts: 5458 |
|
|
| 13 Jul 2014 01:32 AM |
| I don't have any kind of explanation for that behavior... If I had to guess I would go with something like the GC grabbing it by mistake or something? It appears to be a Roblox bug, not your's. Not sure if there's a cleaner way to implement. I tried a for loop of all players but that worked even less... |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2014 03:05 AM |
I think the problem you have is global variables.
Try setting it to: local z = bla
This way the script will not bug out hopefully! |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Jul 2014 08:26 PM |
| You need to use local variables, or everything gets overwritten. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 03:36 PM |
| Thanks for the help. Local Variables did it. I never thought of that. Thank you! |
|
|
| Report Abuse |
|
|