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

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

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

2 comments

0

I'm unsure what you want? Do you want the position of the Handle in the workspace?

0

Your script is only printing the X position of the handle. You should just do Handle.Position, not Handle.Position.X

2 answers

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

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