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

I am trying to print the position of a part in a tool. Anyone able to help?

Asked by 2 years ago

Hello, Gigachads of scriptinghelpers.org

I am attempting to print the position(only the X for now) of the 'handle' in my tool.

My use for this is to create a extremely simple gun, but that is not important, just a little backstory.

local tool = script.Parent
tool.Activated:Connect(function()
    print(game.StarterPack.Gun.Handle.Position.X)
end)

Output: 66

I am unsure as to why this is happening, but some clarification on what I have messed up on would be much appreciated; along with some of my fixed code(if possible).

Thanks in advance Gigachads,

IsaacFriend808

0
I'm unsure what you want? Do you want the position of the Handle in the workspace? MarkedTomato 810 — 2y
0
Your script is only printing the X position of the handle. You should just do Handle.Position, not Handle.Position.X DietCokeTastesGood 111 — 2y

2 answers

Log in to vote
0
Answered by
zomspi 541 Moderation Voter
2 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

66 is the position of the handle (x)

Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

The starter pack contains the tools that you start with when you join the game, it's like starterGui. So you'll have to print the actual handle by writing this instead

local tool = script.Parent
local handle = tool.Handle -- Make that wherever the handle is in the tool.
tool.Activated:Connect(function()
    print(handle.Position.X)
    -- Of course you could put more prints in, printing the Y or Z or all of it (XYZ)
end)

I hope that was what you needed

Answer this question