#How to get the position of a Model?
1 messages · Page 1 of 1 (latest)
To get the position of a Model you have to get the position of a part inside that model.
If your model has a PrimaryPart then its best to use that parts position
How can I give it a PrimaryPart? And what even is that? 😅
Oh and also @prime steeple
I am trying to make a humanoid move to my waypoints in order from 1 to end
I have them as childs in order and all but when I use a loop with getchildren they give a table with non ordere children meaning rn my npc just goes to a random order
how can I make it follow it correctly?
Tried to use table.sort and all but just doesnt really work
You can set the primarypart in the properties of your model. Just lick on PrimaryPart and then on the part you want to be the Primary Part.
And A PrimaryPart pretty much is just like the HumanoidRootPart. It acts as the main part of the model.
oooh that's good
Thanks
You have them named 1 2 3 .. etc right?
well, 1 is named start and the last is named end
but the rest is on number
so 1 is the 2nd?
is it important that they are named start and end?
Rename them to 1 2 3 4 5 6
okidoki
then what? 😅
Hold up let me look into one of my old scripts i had the same problem
Why is it that getchildren will give a shuffled table?
So basicly I just had a function which would get the next waypoint based on a current waypoint variable
thats like so not efficient
idk probably has something to do with performence idk
is there a way where I can alter the tables contents to match that from 1-9?
as making a whole function for that sounds like overkill
imo
Probably but that would be complex i think
oh oke
I just did this
I have a variable CurrentPathpoint which could be 1 for example
oh thats neat
So i loop through each pathpoint look if its name is tostring(CurrentPathpoint + 1)
and return that Pathpoint
Does that help?
this will return the number in string right?
cuz you use tostring-tonumber
so you get a numered string
No this returns the waypoint
Because thats what i needed
yeh but the nextpathpointname returns string
that yes
but the function itself returns the instance
then you go through the entire table and look when that path matches the name and return the path thinguy
I think I understand it
thanks 😄
👍
Whats the diff between doing "Index" or "_"
Nothing. Your just naming a variable
People always do "_" because they don't need the index
I like to remind myself what each variable in my code stands for
YOOOO thank you so much man, I used code from a 4y old video for tower defense game before but that broke so now that I tried your method it works!!, this is my code. Dont know if its the best haha
using a while loop to continue walking until the end
Looks good
Nice
Btw I have a question
When you place something in a storage, replicated or server, they don’t get rendered
What if I have a script in there?(as in one of the models in storage) Does this script also get run on the model in storage or only on the cloned ones?
@prime steeple
Oh and is it possible for one script to call a function on another script?
With Bindable functions / events yes
Idk. I'd guess it won't run untill its out of storage
Nvm. I remembered. A script in storage will run once its removed from storage
Ah nice.
Thats good to know
** You are now Level 8! **
Model:GetPivot() returns a cframe of the oivot's position in the world if the model bas no primary part, or the primary part's cframe if it does have one