Hi, I’m working with this simple AI from yellowmustang (thanks Yellow - your free AI are really awesome considering they are free!) and I was wondering if someone could help me with this adjustment. I’m studying the docs about CFrames, and I still don’t totally get them… (sorry sorry)
So the code draws a Part from the turrets head to the character when it Hits.
I am using a random d20 number generator to make it miss sometimes. If my d20 rolls over 14, it misses, under 14 and it hits. depending on whether it hits or misses, it goes to a different function
The code to draw the laser for when it hits is :
local l = Instance.new("Part",script.Parent)--create ray/laser
l.Anchored = true
l.CanCollide = false
l.BrickColor = BrickColor.new("Really red")
l.Material = Enum.Material.Neon
l.Size = Vector3.new(0.2,0.2,(myHead.Position - target.Position).Magnitude)--creates laser size/length
l.CFrame = myHead.CFrame * CFrame.new(0,0,-(myHead.Position - target.Position).Magnitude/2)--creates laser position directly between the heads (the /2 part) and in front of us (negative on z trait)
--
So I’m wondering how to make a copy of this line:
l.Size = Vector3.new(0.2,0.2,(myHead.Position - target.Position).Magnitude)--creates laser size/length
l.CFrame = myHead.CFrame * CFrame.new(0,0,-(myHead.Position - target.Position).Magnitude/2)
But I’d like it to choose a random spot to the side/above the character, and the line should stretch off to infinity (or very far.)
It probably also needs to do a raycast to check that the spot it chooses doesn’t still hit the character (if it picks a spot in front of the character, it would still pass through the character, but not do damage, so I want to avoid that.)
I’ve jiggered it many ways, and my cframe knowledge just doesn’t seem to grow. I’m not smurt enough to understood the CFrame API info, even though I’ve tried and tried… (sorry)
any help appreciated. much !
