generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: MoveTo is not working as expected

Previous Thread :: Next Thread 
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 10:29 PM
This portion of the script is supposed to place a building where a brick called "Highlight" is located. It works fine, but it always ends up being a half-stud off.

function PurchaseBuilding(ID, Location, Rotation)
local NewBuilding = game.ReplicatedStorage.Buildings[Buildings[ID].Name]:Clone()
...
NewBuilding:MoveTo(Vector3.new(Location.X, Height, Location.Y))
print("B:", Vector3.new(Location.X, Location.Y))
...
end

print("A:", Highlight.Position.X, Highlight.Position.Z)
PurchaseBuilding(BuildingID, Vector2.new(Highlight.Position.X, Highlight.Position.Z), Rotation)

The output is something like this:
A: -6 102
B: -6, 102

But in reality, the position of the model becomes this:
-5.5, 3.2, 102

The -5.5, of course, is supposed to be -6. I have no idea why it isn't.

I even tried moving the model in the command line to see if it works there, but even there it didn't; in fact, I get strange results when I try other numbers:

workspace.TEST:MoveTo(Vector3.new(-5.5, 2.4, 102))
> -5.5, 3.2, 102

workspace.TEST:MoveTo(Vector3.new(-6, 2.4, 102))
> -5.5, 3.2, 102

workspace.TEST:MoveTo(Vector3.new(-6.5, 2.4, 102))
> -6.5, 3.2, 102

workspace.TEST:MoveTo(Vector3.new(-7, 2.4, 102))
> -7.5, 3.2, 102

workspace.TEST:MoveTo(Vector3.new(-7.5, 2.4, 102))
> -7.5, 3.2, 102

To add to the confusion, sometimes the same command has varying results. The -6 one has brought it to -5.5 and -6.5 before, and I can't figure out when it goes where.

Why is MoveTo not moving to the proper location?
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
25 Jul 2015 10:37 PM
It offsets by 0.5 studs for some reason, does this in studio as well.
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
25 Jul 2015 10:39 PM
I assume it's some stupid voxel thing, I have no idea honestly. If you try using the move tool in Studio things automatically offset by 0.5.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 10:48 PM
So, it is *supposed* to do that, or is it a bug?
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
25 Jul 2015 10:51 PM
I have no idea, I don't like it though. I think it's stupid, I have no idea why it does that or why it's needed. It's just something that happens.
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
25 Jul 2015 10:53 PM
Model:SetPrimaryPartCFrame(PositionOfWhereItGoes)
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
25 Jul 2015 10:56 PM
SetPrimaryPartCFrame has saved my life so many times. I love that method.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
25 Jul 2015 10:58 PM
It also tends to yield to parts already in the way, which is bad if you want to move buildings. SetPrimaryPartCFrame() always seems to get the job done, though.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 10:59 PM
That was the workaround I was thinking of, but it's going to be a pain in the butt to use that under these circumstances...

I wish Roblox would just make their stuff work properly, ugh
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 11:00 PM
> It also tends to yield to parts already in the way

That's not a problem, I already am checking for that.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
25 Jul 2015 11:00 PM
You probably don't have the PrimaryPart set because you're an idiot.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 11:07 PM
It's because of the variety of buildings

Using SetPrimaryPartCFrame would put it in the ground so I have to make a height offset for each building, whereas MoveTo automatically put it on top of the ground.
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
25 Jul 2015 11:08 PM
have the primary part the lowest one O.o
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
25 Jul 2015 11:09 PM
You still need to have the PrimaryPart set.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 11:12 PM
> have the primary part the lowest one O.o

That would still put it slightly in the ground, because the lowest one still has a height.

I'm planning on putting a separate 'offset' part right underneath each building where the building and the ground meet and making that the primary part. Problem is, there are tons of buildings...
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 11:13 PM
> You still need to have the PrimaryPart set.

I do have it set, but unless I make a separate part underneath the whole model it will be partly underground.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Jul 2015 11:14 PM
> You still need to have the PrimaryPart set.

I do have it set, but unless I make a new one underneath the whole building it will be partly underground.
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
25 Jul 2015 11:14 PM
You are making your game, you will sometimes struggle and have to add a lot. I'm sure that adding one part to all of your buildings wouldn't be the most time consuming thing...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image