local pos = mouse.Hit.p local s = (pos-tool.SmokePart.Position).Magnitude local laser = Instance.new("Part") laser.Name = "Ray" laser.Transparency = .75 laser.CanCollide = false laser.FormFactor = "Custom" laser.Anchored = true laser.BrickColor = BrickColor.new("Really black") laser.Size = Vector3.new(.2,.2, s) laser.CFrame = CFrame.new(pos, tool.SmokePart.Position)*CFrame.new(0,0,-s/2) game.Workspace:FindPartOnRayWithIgnoreList(laser, {game.Workspace}) laser.Parent = workspace game.Debris:AddItem(laser, .75)
The third to last line is the only error printing out "Unable to cast value to Object" can you guys help me and explain to me why this doesnt work, I have multiple versions of the second to last line but I need some help, Thank You!
local ray = Ray.new(Vector3.new(0, 0, 0), Vector3.new(0, -1, 0)) -- Shoots down from the center of the game local laser = Instance.new('Part') --[[ The laser must be a Ray not a part! --]] game.Workspace:FindPartOnRayWithIgnoreList(ray, {laser}) -- If you have Workspace in the table it will ignore every part in the Workspace!!