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
 

Re: so I made a custom chat but...

Previous Thread :: Next Thread 
ArmaVictorem is not online. ArmaVictorem
Joined: 18 Mar 2015
Total Posts: 1332
25 Nov 2016 05:44 AM
I want only the messages made by the players within an X radius of you to show in your chat, I know to use magnitude on this but how exactly?
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
25 Nov 2016 05:59 AM
Wow your avatar is so cool
Report Abuse
supremebloxboy is online. supremebloxboy
Joined: 12 Jun 2010
Total Posts: 424
25 Nov 2016 09:35 AM
for i,v in pairs(game.Players:GetPlayers()) do
if (PLAYER_WHO_CHATTED.Character.Torso.Position - v.Character.Torso.Position).magnitude < 100 then
--Do Stuff Here
end


Report Abuse
Rerumu is not online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
25 Nov 2016 09:54 AM
Stop.
That is wrong in so many ways.
Report Abuse
Ryuzoji is not online. Ryuzoji
Joined: 21 Dec 2015
Total Posts: 937
25 Nov 2016 09:59 AM
Erm so a chat log based on how near you are with another player?
Just use magnitude.

local Radius = 50

for _, v in pairs(game.Players:GetPlayers()) do
if (Speaker.Torso.Position - v.Torso.Position).magnitude <= Radius then
-- Do something that allows players to see the message
end
end
Report Abuse
supremebloxboy is online. supremebloxboy
Joined: 12 Jun 2010
Total Posts: 424
25 Nov 2016 10:08 AM
####### Says its wrong but doesnt say why nor give better more effective code
Report Abuse
Rerumu is not online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
25 Nov 2016 10:10 AM
-- You're making me suffer.

local Me = (myplayer.Character or myplayer.CharacterAdded:wait()):WaitForChild('Torso');
local X = 50 -- Distance.

-- When receiving...

for _, User in ipairs(game:GetService('Players'):GetPlayers()) do
local Char = User.Character;
if Char and ((((Char:FindFirstChild('Torso') and Char.Torso.Position) or Me.Position) - Me.Position).magnitude <= X then
-- Receive.
end
end
Report Abuse
Rerumu is not online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
25 Nov 2016 10:12 AM
@supreme

Missing an end.
Using "pairs" for an array.
Not checking if the player has a character.
Not checking if the character has a torso.
Report Abuse
Ryuzoji is not online. Ryuzoji
Joined: 21 Dec 2015
Total Posts: 937
25 Nov 2016 10:13 AM
####### He only pointed out the basic structure on how to use it. Of course, there will be errors with the code. You basically did the same exact thing, only thing you added new was actual variables and actually waiting for the character. Jesus, so many cancerous people these days.
Report Abuse
Rerumu is not online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
25 Nov 2016 10:15 AM
It's not cancerous to invalidate misinformation, especially when it would error before even running.
Report Abuse
Ryuzoji is not online. Ryuzoji
Joined: 21 Dec 2015
Total Posts: 937
25 Nov 2016 10:17 AM
"Missing an end."
"He only pointed out the basic structure on how to use it."

"Using "pairs" for an array."
They both work either way.

"Not checking if the player has a character."
Are you serious? Of course it has a character. The only case this it would not if it falls out the map or something.

"Not checking if the character has a torso."
^ Jesus, you don't have to be so cancerous.

Again, "He only pointed out the basic structure on how to use it."
Report Abuse
Rerumu is not online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
25 Nov 2016 10:20 AM
Players don't have a character until they respawn after they die.
Characters without a torso or no character errors instantly.
You can't compile something with a syntax error.
Using pairs on arrays is much slower, not to mention useless key lookups where there are none.

Are you trolling or just plain stupid?
Report Abuse
Ryuzoji is not online. Ryuzoji
Joined: 21 Dec 2015
Total Posts: 937
25 Nov 2016 10:24 AM
Read what I said again.

I said using pairs and ipairs would work either way. Never said ipairs was bad.
And again, I told you, we are just showing the basic outline on how to use magnitude to detect players in a 100 studs radius.
Report Abuse
Ryuzoji is not online. Ryuzoji
Joined: 21 Dec 2015
Total Posts: 937
25 Nov 2016 10:26 AM
And I guess you're right about the Character.
Report Abuse
Rerumu is not online. Rerumu
Joined: 11 Oct 2014
Total Posts: 950
25 Nov 2016 10:27 AM
You're still creating bad habits, and not really helping anyone. Pairs was not made for only arrays, people should know that so they don't start wondering why their code is slow. Same with syntax, if it ain't right they won't know what to do.
Report Abuse
vastqud is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
25 Nov 2016 10:28 AM
rer, you effectively did the same thing that the other guy did, but with a few changes.

his script wasn't wrong, it just wasn't perfect. it was just the basic structure of how to do it
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