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

Previous Thread :: Next Thread 
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
13 Jul 2014 12:41 AM
The coroutine didn't fix it... any other ideas?
Report Abuse
aboy5643 is not online. 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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
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 is not online. 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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
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 is not online. 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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
13 Jul 2014 01:09 AM
Well it is not hard to recreate... just a ScreenGui with a Frame in it.
Report Abuse
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
13 Jul 2014 01:12 AM
bump
Report Abuse
aboy5643 is not online. 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 is not online. 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
Brickman2010 is not online. Brickman2010
Joined: 20 Nov 2009
Total Posts: 5547
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
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
16 Jul 2014 08:24 PM
It's not a bug...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
16 Jul 2014 08:26 PM
You need to use local variables, or everything gets overwritten.
Report Abuse
SuperiorEternal is not online. SuperiorEternal
Joined: 22 Aug 2009
Total Posts: 2365
30 Jul 2014 03:36 PM
Thanks for the help. Local Variables did it. I never thought of that. Thank you!
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