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

How do i find the position of the player?

in this script I clone a seat from server storage when I equip a tool and when I have the tool unequipped it destroys it but the one thing I can't figure out is how to set its position to the player when I clone it also when giving an answer if you can explain how it works so I know what to do in the future that would be great!

here's the code:~~~~~~~~~~~~~~~~~ local tool = script.Parent local car = game.ServerStorage.Car

tool.Equipped:Connect(function(plr) local copy = car:Clone() copy.Parent = game.Workspace copy:MoveTo() tool.Unequipped:Connect(function() copy:Destroy() end) end)


2 answers

✓ Accepted answer

Hi, so if the player is holding the tool, it will give you the coords. Here's an example:

local player = game:GetService("Players").LocalPlayer -- Put :GetService("") if its a service (Workspace, Players, etc.).
local char = player.Character or player.CharacterAdded:Wait() -- Locates the character of player.

local tool = script.Parent


tool.Equipped:Connect(function()
	local humRoot = char:WaitForChild("HumanoidRootPart") -- Locates the HumanoidRootPart of player.
	print(humRoot.Position) -- Printing the position of HumanoidRootPart, which is the primary part of a player.
end)

You can ask why it's not working, else good day.

10 comments

0

Didn't saw the post above, but ok, you can use his answer as a result if his is working.

0

hey it didn't work I tried it and it gave me an error message attempt to index nil with "Character"

0

Is it on a local script? If not, then this is the problem.

0

Also, "Character" is only accessable on a local script.

0

OH OK THANK YOU!

0

No problem :D

0

for some reason it has stopped my other touch detector script from working?

0

Put it on another script, should solve this.

0

no I mean when I set the position of the touch detector (witch is what I'm cloning) it stops it from detecting anything

0

if I put this code into a local script it stops the touch detector from detecting anything I tested it with a server script and the touch detector started working again

This is really simple and easy, all you need to do is this:

local Character = plr.Character local Humrp = Character:WaitForChild("HumanoidRootPart")

local Position = Humrp.Position

That gives you the players position.

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