I’m making a flag that you can place on the ground, so I’m using raycasting, which returns where the ray collided with the ground, and the direction of the ray, how do I use only that first value?
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
tool.Activated:Connect(function()
local origin = handle.Position
local direction = Vector3.new(0,-50,0)
local newRay = Ray.new(origin,direction)
end)
I’m not quite sure what you mean with ‘that first value’, but I am assuming you want to place the flag on the position where the Rayast hit. If so, it is doable by obtaining the .Position of the newRay.
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
tool.Activated:Connect(function()
local origin = handle.Position
local direction = Vector3.new(0,-50,0)
local newRay = Ray.new(origin,direction)
if newRay then --//Check if the ray successfully hit an object. This will result `nil` if it failed, thus not running the code.
print(ray.Position)
handle.Position = ray.Position --//Play with these values if not accurate by adding a Vector3.new()
end
end)