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 » Scripting Helpers
Home Search
 

Re: Moving Block To Mouse Position on BasePlate

Previous Thread :: Next Thread 
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 05:59 PM
I've tried this, no errors but it does not clone to where the Player Mouse Position is, it just spawns off the BasePlate, not that far away.

Script Below v;

local player = game.Players.LocalPlayer
Mouse = player:GetMouse()
Mouse.Button1Down:connect(function()

while wait() do
if Mouse.Target.Name == "Create" then
block = Mouse.Target
new = Mouse.Target:Clone()
new.Parent = game.Workspace
new.Position = Vector3.new(Mouse.X, 4.19, Mouse.Y)
new.Color = BrickColor.Random().Color

end
break
end
end)

Any help?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 06:03 PM
Mouse.X is the position on the SCREEN, not the WORLD.

Use Mouse.Hit.X and Mouse.Hit.Z
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
19 Jun 2014 06:04 PM
Vector3.new(Mouse.X, 4.19, Mouse.Y)

Screen position isn't the same as world position. Use mouse.Hit instead.

(Also that while loop is completely redundant)
Report Abuse
cxcharlie is not online. cxcharlie
Joined: 26 Aug 2009
Total Posts: 1414
19 Jun 2014 06:04 PM
local player = game.Players.LocalPlayer
Mouse = player:GetMouse()
Mouse.Button1Down:connect(function()

while wait() do
if Mouse.Target.Name == "Create" then
block = Mouse.Target
new = Mouse.Target:Clone()
new.Parent = game.Workspace
new.Position = Vector3.new(Mouse.Hit.p.x, 4.19, Mouse.Hit.p.y)
new.Color = BrickColor.Random().Color
break
end
end
end)
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:07 PM
It spawns closer, like 10 feet close to it but not at the Clicked Position. Maybe I can work around it.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 06:07 PM
@cxcharlie: Last I checked CFrame had X, Y and Z values, making the .p useless. Also, he probably wants Hit.z for the Z component.
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:08 PM
@Rofl I know that.
I used the Mouses X and Y to calculate where the block will go on the screen and 4.19 is weird it should spawn above the baseplate.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 06:09 PM
Are you sure you are converting X and Y to the world space correctly?
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:10 PM
@cx It spawns closer to the block but It isn't at it's direct location.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 06:11 PM
Can you link me to somewhere I can test the script to see the issue for myself?
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:12 PM
Okay
http://www.roblox.com/item.aspx?id=141123951
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:15 PM
It spawns closer to the part itself but not the actual Mouse Position
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
19 Jun 2014 06:22 PM
local player = game.Players.LocalPlayer
Mouse = player:GetMouse()
Mouse.Button1Down:connect(function()
target = Mouse.Target
if target and target.Name == 'Create' then
new = target:Clone()
new.Parent = workspace
new.CFrame = CFrame.new(Mouse.hit.X, 4.19, Mouse.hit.Z)--I'm assuming you meant Z
new.Color = BrickColor.Random().Color
end
end)
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:25 PM
Notunknown helped me fix it, ty :)

[Closed]
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 06:25 PM
And @Cool too.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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