Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i find the position of the player?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

0
Didn't saw the post above, but ok, you can use his answer as a result if his is working. R4nd0ml0l2 105 — 3y
0
hey it didn't work I tried it and it gave me an error message attempt to index nil with "Character" Leviathan458 2 — 3y
0
Is it on a local script? If not, then this is the problem. R4nd0ml0l2 105 — 3y
0
Also, "Character" is only accessable on a local script. R4nd0ml0l2 105 — 3y
View all comments (6 more)
0
OH OK THANK YOU! Leviathan458 2 — 3y
0
No problem :D R4nd0ml0l2 105 — 3y
0
for some reason it has stopped my other touch detector script from working? Leviathan458 2 — 3y
0
Put it on another script, should solve this. R4nd0ml0l2 105 — 3y
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 Leviathan458 2 — 3y
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 Leviathan458 2 — 3y
Ad
Log in to vote
0
Answered by
Desmondo1 121
3 years ago

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.

Answer this question