Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I want a player's position but it isn't working? Read desc.

So i want if a player moves the position from torso? But it isn't working to even print it... I want that the position is rounded to like 2 and not 2,204049239 ? So could anyone help me? Its a local script and it is in a GUI.

wait()
local player = game.Players.LocalPlayer
local character =  player.Character:FindFirstChild("Torso")
while true do
	script.Parent.PositionReal.Text = math.floor(character.Position.X)",".. math.floor(character.Position.Y) ..",".. math.floor(character.Position.X)
end

error: attempt to call a number value

2 comments

0

I'm not sure a changed event works for Position. It doesn't really matter either I think, with animations and such this changes so often you might as well just use a while loop.

0

Okey thank you! But now the other things

2 answers

✓ Accepted answer

You can actually do something like this (though your way is correct)...

character.Changed:Connect(function(property)
	if string.lower(property) == "position" then -- Can't remember if they come in capitalized
		print("X -" ..math.floor(character.Position.X))
		print("Y -" ..math.floor(character.Position.Y))
		print("Z -" ..math.floor(character.Position.Z))
	end
end)

You can use math.floor to round down and math.ceil to round up. You could even use math.modf to split the decimal from the integer which is technically the same as math.floor except that you can keep the decimal for other use.

https://wiki.roblox.com/index.php?title=Global_namespace/Mathematical_functions

4 comments

0

Do u know how u doe like between in lau like if position is between 1,1,1 2,2,2 then?

0

Might be able to use Region3

0

And how to use that?

Try and access the Torso through the workspace.

local playername = game.Players.LocalPlayer.Name
local playermodel = game.workspace:FindFirstChild(playername)
local Torso = playermodel:FindFirstChild(Torso)

1 comment

0

It is laready working but if u know a way to get if player is between posotion 1,1,1 and 4,4,4 ?

This discussion is preserved as it was. New answers, comments, and votes are closed.