leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 03:13 PM |
How can I clone an object on top of another Brick using TargetSurface? Tried this and ain't working.
local plr = game.Players.LocalPlayer mouse = plr:GetMouse()
mouse.Button1Down:connect(function() local object = game.ReplicatedStorage.Prefabs:WaitForChild("Object") if not mouse.Target then else if mouse.Target:IsA("BasePart") then object:Clone().Parent = game.Workspace.PlacedObjects print(mouse.TargetSurface) object.CFrame = mouse.TargetSurface else end end end) |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 03:42 PM |
| bump #3 I'm slowly dieing. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Aug 2016 03:44 PM |
You can't do that with TargetSurface. Targetsurface just sets the surfacetpe. Thats it.
|
|
|
| Report Abuse |
|
|
pidgey
|
  |
| Joined: 16 Jan 2008 |
| Total Posts: 2739 |
|
|
| 03 Aug 2016 03:45 PM |
TargetSurface Enums Name Value Right 0 Top 1 Back 2 Left 3 Bottom 4 Front 5
https://www.roblox.com/My/Groups.aspx?gid=2893266 | pidgey is my name sh##posting is my game |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 03:51 PM |
| Then how can I go by doing this? I tried using Rays but they didn't work.Sorta like in how in Minecraft your able to place blocks on the face of another. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Aug 2016 03:51 PM |
Rays would be the best way. just tweek them more and you'll figure it out
|
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 03:54 PM |
did you try casting a ray in every facial direction
Add 13,000 posts |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 03:55 PM |
I tried this but no success and I've been at this for the past 2 days xD.
local object = UIBar.Slot1.Slot.ItemObj.Value:Clone() object.Parent = game.Workspace.PlacedBlocks local ray = Ray.new(game.Workspace.CurrentCamera.CFrame.p, hitp) local part, hit, surfaceVector = workspace:FindPartOnRay(ray) if not part then return end surfaceVector = surfaceVector * part.Size.X/2 object.CFrame = part.CFrame * CFrame.new(surfaceVector)
|
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 03:56 PM |
| Thats the thing I don't kow how to get facial directions or clone the object there?! |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 03:57 PM |
here is what you do
for every face of the object, cast a ray in its direction
if it hits an object, u now know which face it's hitting
local RightVector = cframe:vectorToWorldSpace( Vector3.new(1,0,0) ) local LeftVector = cframe:vectorToWorldSpace( Vector3.new(-1,0,0) ) local UpVector = cframe:vectorToWorldSpace( Vector3.new(0,1,0) ) local DownVector = cframe:vectorToWorldSpace( Vector3.new(0,-1,0) ) local FrontVector = cframe.lookVector local BackVector = cframe.lookVector*-1
for every one of these i would cast a ray in the direction
Add 13,000 posts |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Aug 2016 04:00 PM |
@lord there is no point in doing that when u just cast a ray from the mouse position and then just directly get the face
|
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 04:00 PM |
@Narwhal
Or just
local Normal = cframe:vectorToWorldSpace(Vector3.FromNormalId(TargetSurface)) |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 04:00 PM |
@Time
maybe i like to overcomplicate everything
Add 13,000 posts |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 04:01 PM |
| I might sound like a total noob but I don't know how to cast the direction I tried what I did and failed and wiki isn't so helpful so can I see a example? Sorry if I sound terrible xD. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Aug 2016 04:02 PM |
same principal from this wiki
http://wiki.roblox.com/index.php?title=Making_a_ray-casting_laser_gun
|
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 04:05 PM |
| So the first argument is the object position? Which is object.CFrame.p and the second position is the mouse position which is mouse.Hit.p? Is that right?? |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 06:41 PM |
I get vectorToWorldSpace nil value error when using the raycast. And also how can I get it to be placeable on all sides when it works? Here is my code:
local plr = game.Players.LocalPlayer mouse = plr:GetMouse()
mouse.Button1Down:connect(function() local object = game.ReplicatedStorage.Prefabs:WaitForChild("Object") if not mouse.Target then else if mouse.Target:IsA("BasePart") then local object = game.ReplicatedStorage.Prefabs.Object:Clone() object.Parent = game.Workspace.PlacedObjects local ray = Ray.new(object.CFrame.p,mouse.hit.p) local raycast = CFrame:vectorToWorldSpace(Vector3.FromNormalId(Enum.NormalId.Top)) --object.CFrame = mouse.Hit-- else end end end) |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 03 Aug 2016 07:35 PM |
| Help I've been at this for the past 2 days xD. |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|