The method returns a vector3 not a CFrame so that’s why you’re getting the error.
What are you trying to do? Maybe we can help more if you elaborate. Right now it seems like you’re just throwing methods you don’t understand at the wall and seeing what sticks.
local weapon = script.Parent
local enabled = true
local dazed = game.ServerStorage.KatanaDiversity.Dazed2
local rdazed = game.ServerStorage.KatanaDiversity.RevertedDazed
local Char = weapon.Parent.Parent
local RootPart = Char.HumanoidRootPart
local IL = {}
print("Check1")
local RAY = Ray.new(RootPart.Position, RootPart.CFrame.LookVector * 100)
local RayPos,HitPos = workspace:FindPartOnRayWithIgnoreList(RAY, IL, false, true)
print("Check2")
local Hits = {}
table.insert(Hits, HitPos)
for index,Items in ipairs(Hits) do
if not Items then
print("no items")
end
HIt = Items
print(Items)
end
local part = Instance.new("Part")
part.Anchored = true
if HIt then
magnitude = (RootPart.Position - HIt).Magnitude
else
magnitude = 100
end
part.Size = Vector3.new(1,1, magnitude)
local pos = Vector3.new(0,0,-50)
part.CFrame = CFrame.new(RootPart.Position,RootPart.CFrame.LookVector)
local newpos = part.CFrame:PointToWorldSpace(pos)
part.CFrame = CFrame.new(newpos,RootPart.CFrame.LookVector)
part.CanCollide = false
part.Parent = RootPart
So you’re just trying to draw a line between the ray and the hit position? No need for any conversion to/from world space everything you need is already converted.
local PART = Instance.new("Part")
PART.Size = Vector3.new(0.1, 0.1, 0.1)
PART.Anchored = true
PART.CanCollide = false
PART.TopSurface = Enum.SurfaceType.Smooth
PART.BottomSurface = Enum.SurfaceType.Smooth
PART.Material = Enum.Material.SmoothPlastic
local function drawLine(a, b)
local line = PART:Clone()
line.CFrame = CFrame.new((a + b)/2, b)
line.Size = Vector3.new(0.1, 0.1, (b - a).Magnitude)
line.Color = Color3.new(1, 1, 0)
return line
end
-- example use
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local mouse = game.Players.LocalPlayer:GetMouse()
local lastLine = nil
tool.Activated:Connect(function()
local ray = Ray.new(handle.Position, (mouse.Hit.p - handle.Position).Unit*1000)
local hit, pos, normal = workspace:FindPartOnRay(ray, tool.Parent)
if (lastLine) then
lastLine:Destroy()
end
lastLine = drawLine(ray.Origin, pos)
lastLine.Parent = tool
end)