|
Hello, Trying to get the position of the Handle inside a tool however all I am getting is Handle not a valid member of Part but yet if I remove the handle and try to find the position I get the same thing.
Can anyone help me please?
Pos = Tool.handle.position |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Make sure that Handle is capitalized the same way in your script as it is in your tool. I notice you are using lower case but I think generally it's called the Handle in most tools.
|
|
|
I changed the Handle to be capitalised and I'm still receiving the same error |
|
|
Can you please post your script here? (The whole thing!!)
It's just roblox, deal with it. |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Handle, then, is not a child of Tool directly. Make sure it's pathed correctly.
The output error also says that "Handle is not a valid member of Part" which means that you're not calling from a Tool object, but instead, an actual part.
|
|
|
The Handle is the name of the part inside the Tool
for i=1, #toys do
toys[i].Handle.Position = Vector3.new(0, 50, 0)
end
Thankyou |
|
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Gonna need the whole script, that looks like a fragment. Handle is not where you specified it to be - we need to figure out where it actually is.
|
|
|
local function Weld(x,y)
local W = Instance.new("Weld",x)
W.Part0 = x
W.Part1 = y
local CJ = CFrame.new(x.Position)
local C0 = x.CFrame:inverse()*CJ
local C1 = y.CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
end
local toys = script.Parent.Parent.Parent.Parent.Parent.Toys:GetChildren()
while true do
for i=1, #toys do
if toys[i].Name == "Minion" then
if(toys[i].Handle.Position - script.Parent.Position).magnitude <=1 then
print("Tada")
Weld(toys[i], script.Parent)
end
end
end
wait()
script.Disabled=true
end |
|
|
We will also need the parent-child relations: Where exactly the script is located. For example:
"script is located in a Part which is in a Model which is in a Tool" |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
That is referenced..
local toys = script.Parent.Parent.Parent.Parent.Parent.Toys:GetChildren()
|
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Can't imagine that it's a problem with the code; it looks proper to me.
I've taken that second if-then statement and bundled it with the previous conditional using 'and'. See if that affects anything, but I don't think it should.
As long as everything in 'toys' is a parent to a part named Handle, it should be OK.
while true do
for i=1, #toys do
if toys[i].Name == "Minion" and (toys[i].Handle.Position - script.Parent.Position).magnitude <=1 then
print("Tada")
Weld(toys[i], script.Parent)
end
end
wait()
script.Disabled=true
end
|
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Well, everything referenced by toys[i] that is.
...you know what I mean. :)
|
|
|
Hmm :/ I really dont know whats wrong hahah
This is the error im getting still
10:44:33.831 - Position is not a valid member of Tool
10:44:33.832 - Script 'Workspace.Model.Down.Play', Line 38
10:44:33.833 - Stack End
Btw, Thankyou for taking your time helping me! I really appreciate it |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Tools have no position, only Parts do.
More critically, though, that looks like an error from a different script entirely. The code I'm looking at only has 29 lines, not 38.
Since this is so convoluted with regard to pathing, would you be willing to publish and uncopylock the place you're working in? Or, if that's unappealing, create a mock-place with the same pathing of the critical items?
|
|
|
Tools do have a position
Or maybe its called something else I don't remember
Can you upload the tool as a model for testing |
|
SoybeenJoin Date: 2010-02-17 Post Count: 21462 |
Tools only use Grips that affect the position and rotation of the Handle. If you're trying to figure out the position of a tool, it's best to go by a central part, similar to how you'd get a Model's general position.
|
|