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: Making a script that prints (X,Y,Z) position of player?

Previous Thread :: Next Thread 
Contrary is not online. Contrary
Joined: 08 Jan 2011
Total Posts: 1306
05 Sep 2015 03:53 PM
Hello, I'm trying to make script that prints the (X,Y,Z) position of the LocalPlayer whenever they move. I tried making a function, but I know it isn't correct. How do I make this work?

player = player = game.Players.LocalPlayer

player.Changed:connect(function()
local plrPos = player.Character.Torso.Position
print (plrPos)
end)
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
05 Sep 2015 03:55 PM
print(tostring(plrPos)

maybe?
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Sep 2015 03:56 PM
local player = game.Players.LocalPlayer;
local char = player.Character or player.CharacterAdded:wait();
local torso = char:WaitForChild("Torso")

torso.Changed:connect(function()
print(torso.Position)
end)
Report Abuse
Contrary is not online. Contrary
Joined: 08 Jan 2011
Total Posts: 1306
05 Sep 2015 03:56 PM
Well, what I'm curious about is how the function knows what property it's look for to be changed.

Like, there are tons of properties that are being changed on the character when it moves... not just position.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Sep 2015 03:58 PM
local player = game.Players.LocalPlayer;
local char = player.Character or player.CharacterAdded:wait();
local torso = char:WaitForChild("Torso")

torso.Changed:connect(function(property)
if property == "Position" then
print(torso.Position)
end
end)
Report Abuse
Contrary is not online. Contrary
Joined: 08 Jan 2011
Total Posts: 1306
05 Sep 2015 04:02 PM
Ah, thanks!
Report Abuse
Contrary is not online. Contrary
Joined: 08 Jan 2011
Total Posts: 1306
05 Sep 2015 04:09 PM
Hmm... it oddly only seems to print it once, which is right when I spawn. It doesn't seem to print it every time I move.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
05 Sep 2015 04:11 PM
Properties that are Vector3s, CFrames, etc do not trigger the Changed event on change
Report Abuse
Contrary is not online. Contrary
Joined: 08 Jan 2011
Total Posts: 1306
05 Sep 2015 04:11 PM
Do you what properties do? I could use one of those properties that trigger it, then just have it print the position.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
05 Sep 2015 04:13 PM
I'm pretty sure that all basic Lua datatypes fire the Changed event upon changed (e.g numbers, strings). Honestly, I would just use a loop, ik people don't approve of loops like this but whatever
Report Abuse
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
05 Sep 2015 04:13 PM
I think this guy is a time traveller, he types like he's in the late 1600's
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
05 Sep 2015 04:14 PM
I don't know then lol

This code is NOT ideal if you're printing because it'll print every 1/60 of a second, but if you want to update a GUI with your cords, it's great.

local player = game.Players.LocalPlayer;
local char = player.Character or player.CharacterAdded:wait();
local torso = char:WaitForChild("Torso")

game:GetService("RunService").RenderStepped:connect(function()
print(torso.Position)
end)
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
05 Sep 2015 04:15 PM
Also, @Wowgnomes

the print function already uses tostring() on the arguments so it is not necessary
Report Abuse
Contrary is not online. Contrary
Joined: 08 Jan 2011
Total Posts: 1306
05 Sep 2015 04:15 PM
What? Who's typing like they are from the late 1600's?
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
05 Sep 2015 04:35 PM
it's not necessary but is it wrong
Report Abuse
adamhunter123 is not online. adamhunter123
Joined: 02 Oct 2009
Total Posts: 40
05 Sep 2015 05:07 PM
( ͡° ͜ʖ ͡°)
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