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: Brick at Mouse's Position

Previous Thread :: Next Thread 
BossfightX is not online. BossfightX
Joined: 06 Feb 2010
Total Posts: 2962
06 Feb 2015 05:33 PM
I'm trying to make it so that way it creates a new brick and puts the bricks position to where the mouse is, and it ain't working!

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local part = Instance.new("Part", game.Workspace)
part.FormFactor = "Custom"
part.Size = Vector3.new(2,0.4,2)
part.BrickColor = BrickColor.new("Lime Green")
while true do
part.CoordinateFrame = CFrame.new(mouse.Hit)
wait()
end
Report Abuse
juniorjfive is not online. juniorjfive
Joined: 05 Jan 2010
Total Posts: 671
06 Feb 2015 05:38 PM
Replace
while true do
part.CoordinateFrame = CFrame.new(mouse.Hit)
wait()
end


with

mouse.Move:connect(function()
if mouse.Hit~=nil then
part.CFrame=mouse.Hit
end
end)

Remember, Part's use CFrame, not CoordinateFrame. CoordinateFrame's are for the Camera's, which is the same as CFrame but is used for the Camera only. I removed your loop because the "Move" connection may quantify your script by giving it a faster response than the infinite loop that delays by .03
Report Abuse
BossfightX is not online. BossfightX
Joined: 06 Feb 2010
Total Posts: 2962
06 Feb 2015 05:58 PM
Okay, it works, but the brick faces the camera and I don't want that.
Report Abuse
juniorjfive is not online. juniorjfive
Joined: 05 Jan 2010
Total Posts: 671
06 Feb 2015 06:01 PM
Now you need to play around with the CFrame. View the CFrame category in the wiki and come up with your solution.

http://wiki.roblox.com/index.php?title=CFrame
Report Abuse
BossfightX is not online. BossfightX
Joined: 06 Feb 2010
Total Posts: 2962
06 Feb 2015 06:03 PM
I attempted to use CFrame.Angles when I just posted that reply. It really doesn't fix it and it just moves the brick towards the camera.
Report Abuse
BossfightX is not online. BossfightX
Joined: 06 Feb 2010
Total Posts: 2962
06 Feb 2015 06:08 PM
I just attempted to use this line

part.CFrame = CFrame.new(mouse.Hit.p)


This seems to fix the rotation problem, but the brick still goes towards the camera. Now I don't know how to solve it from here.
Report Abuse
juniorjfive is not online. juniorjfive
Joined: 05 Jan 2010
Total Posts: 671
06 Feb 2015 06:15 PM
Not efficient, but it should work.
part.CFrame=CFrame.new(mouse.Hit.X,(mouse.Hit.Y+(part.Size.Y*5)),mouse.Hit.Z)
Report Abuse
BossfightX is not online. BossfightX
Joined: 06 Feb 2010
Total Posts: 2962
06 Feb 2015 06:22 PM
Good, don't like how it hovers, but good enough.

I added this at the end because if the person dies, a new brick is created and the old one will stay there forever.

human.Died:connect(function()
part:Destroy()
end)
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
06 Feb 2015 06:23 PM
check the parts position/cframe? round it to the next .5?

example if the position is 4.324234324, 1, -3.65 then

round it to 4.5, 1, -3.5

and then make it's rotation rounded to the nearest 90 mark? example:

-180, 0, -180

90, 0, 0

0,0,0

180, 0, 180
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
06 Feb 2015 06:23 PM
that should snap it to the stud grid
Report Abuse
BossfightX is not online. BossfightX
Joined: 06 Feb 2010
Total Posts: 2962
06 Feb 2015 07:15 PM
all that remains as an issue is make it so that way the brick doesn't go towards the camera, junior's code works most of the time except from an above view, I just want it so it doesn't go towards the camera (Such as the mouse being on the part and then it move the part up, the mouse is still on it and it goes up more. This goes in a loop until the brick goes behind the camera)


Take the green disc from older roblox (If anyone remembers it). The disc acts similar to this script, except it doesn't fly off towards the camera, how did they do that?
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