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: TargetSurface

Previous Thread :: Next Thread 
leomesa is not online. 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 is not online. leomesa
Joined: 11 Apr 2014
Total Posts: 1029
03 Aug 2016 03:16 PM
bump
Report Abuse
leomesa is not online. leomesa
Joined: 11 Apr 2014
Total Posts: 1029
03 Aug 2016 03:29 PM
bbump
Report Abuse
leomesa is not online. leomesa
Joined: 11 Apr 2014
Total Posts: 1029
03 Aug 2016 03:42 PM
bump #3 I'm slowly dieing.
Report Abuse
TimeTicks is not online. 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 is not online. 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 is not online. 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 is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
03 Aug 2016 03:54 PM
did you try casting a ray in every facial direction




Add 13,000 posts
Report Abuse
leomesa is not online. 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 is not online. 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
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
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 is not online. 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
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
03 Aug 2016 04:00 PM
@Narwhal

Or just

local Normal = cframe:vectorToWorldSpace(Vector3.FromNormalId(TargetSurface))
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
03 Aug 2016 04:00 PM
@Time

maybe i like to overcomplicate everything




Add 13,000 posts
Report Abuse
leomesa is not online. 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 is not online. 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 is not online. 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 is not online. leomesa
Joined: 11 Apr 2014
Total Posts: 1029
03 Aug 2016 05:08 PM
bump
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
03 Aug 2016 05:09 PM
.p = vector3 position


Report Abuse
leomesa is not online. leomesa
Joined: 11 Apr 2014
Total Posts: 1029
03 Aug 2016 05:09 PM
double bumpp
Report Abuse
leomesa is not online. 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 is not online. 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 is not online. leomesa
Joined: 11 Apr 2014
Total Posts: 1029
03 Aug 2016 07:59 PM
bbump
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