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

Previous Thread :: Next Thread 
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
02 Nov 2015 04:20 AM
I have a tool, kind of a building tool where you can place a building onto a Smooth Terrain map. The problem is, that when I use MoveTo(mouse.Hit.p) it CFrames the building through the terrain, while in studio(using the command bar) it places the model on top of the terrain, which is exactly what I want to happen. However, this doesn't happen when I try to do it with a tool, also the y-coordinate seems to be always 0 for some reason... When I do this:
print(mouse.Hit.p.y) it doesn't say 0, but the building really is placed at a 0 y-coordinate

Can someone please help me out?
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
02 Nov 2015 04:22 AM
Setting the CFrame property ignores collisions. Using :MoveTo() does not.
Post code pls
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
02 Nov 2015 04:25 AM
b:MoveTo(Vector3.new(9999, 99999999999, 9999))
local hit = mouse.Hit.p
print(hit)
local targ = mouse.Target
if targ and targ.Name == "Terrain" then
b:MoveTo(Vector3.new(math.ceil(hit.x), math.ceil(hit.y), math.ceil(hit.z)))
print(hit.y, b:GetModelCFrame().p.y)

I use MoveTo because I don't want it to ignore collisions, but somehow it does anyway. the last print gives me this:

Actual y-coordinate of mouse.Hit.p.y, 0
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
02 Nov 2015 04:32 AM
b.Parent = nil
local hit = mouse.Hit.p
local x = math.floor(hit.X+.5)
local y = math.floor(hit.Y+.5)
local z = math.floor(hit.Z+.5)
local target = mouse.Target
b.Parent = game.Workspace
if tostring(target) == "Terrain" then
b:MoveTo(Vector3.new(x,y,z))
end

Dunno, try this
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
02 Nov 2015 04:36 AM
I don't know what magic you used, but it worked xD

your version should be exactly the same as mine, right? How come yours worked xD

Anyway, thanks a lot!
Report Abuse
scottmike0 is not online. scottmike0
Joined: 14 Sep 2008
Total Posts: 1073
02 Nov 2015 04:50 AM
he used the opposite of math.ceil()
he used math.floor
he used toString, which is similar to yours
I do not understand the .5, but whatevs
anyways you may have just used the wrong function of the math property
Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
02 Nov 2015 04:54 AM
using floor didn't solve the problem, i used ceil and it has the same effect, as well as when i remove the +.5
Report Abuse
scottmike0 is not online. scottmike0
Joined: 14 Sep 2008
Total Posts: 1073
02 Nov 2015 04:58 AM
then your starting b was the incorrect
as you see b.Parent = Nil
versus your b.MoveTo
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