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 » Game Design
Home Search
 

Re: Round this to nearest stud?

Previous Thread :: Next Thread 
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:06 PM
model:MoveTo(mouse.hit.p)

model is a model that will be placed when you click on your baseplate. it's position is going to be where you click (Ask me if you need more code but this is what i was working on)
Report Abuse
Vaae is not online. Vaae
Joined: 06 May 2013
Total Posts: 1254
13 Nov 2016 07:20 PM
model:MoveTo(mouse.Hit.p.X%1, mouse.Hit.p.Y%1, mouse.Hit.p.Z%1)

I believe that'll work, either that or I'm a little too messed up right now if ya feel me haha
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:21 PM
i will try that now
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:22 PM
Every time i try (Including yours) to round it gives me this error:

Unable to cast double to Vector3
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:23 PM
Do you know what that means?
Report Abuse
Vaae is not online. Vaae
Joined: 06 May 2013
Total Posts: 1254
13 Nov 2016 07:25 PM
Made a mistake, sorry.

model:MoveTo(mouse.Hit.p.X - mouse.Hit.p.X%1, mouse.Hit.p.Y - mouse.Hit.p.Y%1, mouse.Hit.p.Z - mouse.Hit.p.Z%1)


Try that.
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:26 PM
kk will do
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:27 PM
same error :(
Report Abuse
Vaae is not online. Vaae
Joined: 06 May 2013
Total Posts: 1254
13 Nov 2016 07:28 PM
Can you post the entire snippet of code around the :MoveTo()?
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:30 PM
function onButton1Down(mouse)
if mouse.Target.Name == "BuildingPlates" then
if mouse.Target.Owner.Value == game.Players.LocalPlayer.Character then
local model = bin.Blueprint:clone()
model.Parent = mouse.Target
model:MakeJoints()
print(mouse.hit.p)
model:MoveTo(mouse.Hit.p.X - mouse.Hit.p.X%1, mouse.Hit.p.Y - mouse.Hit.p.Y%1, mouse.Hit.p.Z - mouse.Hit.p.Z%1)--model:MoveTo(mouse.hit.p)
else
print(mouse.Target.Owner.Value)
print("Fail")
end
else
print("Wrong Part")
end
end

that is the function, and it is called later on with left click
Report Abuse
NukeLuckyLuke is not online. NukeLuckyLuke
Joined: 08 Apr 2016
Total Posts: 5767
13 Nov 2016 07:31 PM
you made a variable for the mouse right??
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:33 PM
No. mouse is the... i forgot what they are called example:

function onButton1Down(mouse)

end
Report Abuse
NukeLuckyLuke is not online. NukeLuckyLuke
Joined: 08 Apr 2016
Total Posts: 5767
13 Nov 2016 07:36 PM
you have to make the variable for the mouse:
local mouse = game.Player:GetMouse()
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:38 PM
Both lead to the same spot though. Does it make a difference?
Report Abuse
NukeLuckyLuke is not online. NukeLuckyLuke
Joined: 08 Apr 2016
Total Posts: 5767
13 Nov 2016 07:40 PM
roblox studio wont know what the heck a mouse is until you specifically make a variable for it. i might possibly be wrong but chances are low
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:44 PM
in the code it does know what the mouse is because mouse is the thing that made the button1down call it and it is in the parenthesees also i tried making a variable got same error

Unable to cast double to Vector3
Report Abuse
Vaae is not online. Vaae
Joined: 06 May 2013
Total Posts: 1254
13 Nov 2016 07:47 PM
Try this, doubt this'll fix it but its worth a try lol, no idea why I can't find the error lol.

model:MoveTo(Vector3.new(mouse.Hit.p.X%1, mouse.Hit.p.Y%1, mouse.Hit.p.Z%1))
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:49 PM
Good news and bad news. the good news is there was no error yay! but the bad news is that it did not place the block where the mouse clicked. it placed it at Vector3.new(0, 0, 0)
Report Abuse
Vaae is not online. Vaae
Joined: 06 May 2013
Total Posts: 1254
13 Nov 2016 07:51 PM
Made a mistake again -_- LOL


model:MoveTo(Vector3.new(mouse.Hit.p.X - mouse.Hit.p.X%1, mouse.Hit.p.Y - mouse.Hit.p.Y%1, mouse.Hit.p.Z - mouse.Hit.p.Z%1))
Report Abuse
trytry1 is not online. trytry1
Joined: 18 Dec 2010
Total Posts: 129
13 Nov 2016 07:54 PM
It worked! thank you. when i was trying i was nowhere near your answer xD.
Report Abuse
Vaae is not online. Vaae
Joined: 06 May 2013
Total Posts: 1254
13 Nov 2016 07:55 PM
No problem haha, can't believe it took me that long to see that I forgot to type vector3.new lmao.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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