hi guys im ctg i need help
rn im struggling on this. I need to set part cframe then make it look a part then make it random rotation
The thing i want
my code:
function module:CreateEnforcerBullet(Tower, Target)
local Model = Instance.new("Model")
Model.Name = "EnforcerBullet"
Model.Parent = workspace.Trash
for i=1, 4 do
local Distance = (Tower.FireRay.Position - Target.HumanoidRootPart.Position).Magnitude
local Mid = (Tower.FireRay.Position + Target.HumanoidRootPart.Position) / 2
local Bullet = ReplicatedStorage.Assets.EnforcerBullet:Clone()
Bullet.CanCollide = false
Bullet.CanQuery = false
Bullet.CanTouch = false
Bullet.Massless = true
Bullet.Anchored = true
Bullet.Size = Vector3.new(0.064, 0.06, Distance)
warn(Mid)
warn(Tower.FireRay.Position, Target.HumanoidRootPart.Position)
Bullet.CFrame = CFrame.new(Mid) * CFrame.new(Tower.FireRay.Position, Target.HumanoidRootPart.Position) * CFrame.Angles(0, math.rad(math.random(0, 45)), 0)
Bullet.Parent = Model
TweenService:Create(Bullet, TweenInfo.new(1), {Transparency = 1}):Play()
end
Debris:AddItem(Model, 1)
end```
2 Likes
tienke
(tienke)
#2
Try this:
function module:CreateEnforcerBullet(Tower, Target)
local Model = Instance.new("Model")
Model.Name = "EnforcerBullet"
Model.Parent = workspace
local Radius = 30
for i=1, 4 do
local Distance = (Tower.FireRay.Position - Target.HumanoidRootPart.Position).Magnitude
--local Mid = (Tower.FireRay.Position + Target.HumanoidRootPart.Position) / 2
local Bullet = ReplicatedStorage.Assets.EnforcerBullet:Clone()
Bullet.CanCollide = false
Bullet.CanQuery = false
Bullet.CanTouch = false
Bullet.Massless = true
Bullet.Anchored = true
Bullet.Size = Vector3.new(0.064, 0.06, Distance)
--warn(Mid)
warn(Tower.Position, Target.HumanoidRootPart.Position)
Bullet.CFrame = CFrame.new(Tower.FireRay.Position)
Bullet.CFrame = CFrame.new(Tower.FireRay.Position, Target.HumanoidRootPart.Position) * CFrame.Angles(math.rad(math.random(-Radius, Radius)), math.rad(math.random(-Radius, Radius)), math.rad(math.random(-Radius, Radius))) * CFrame.new(0, 0, -Bullet.Size.Z/2)
Bullet.Parent = Model
game.TweenService:Create(Bullet, TweenInfo.new(1), {Transparency = 1}):Play()
end
game.Debris:AddItem(Model, 1)
end
You might want to modify some stuff cuz i changed some of it for testing
1 Like
function module:CreateEnforcerBullet(Tower, Target)
local Model = Instance.new("Model")
Model.Name = "EnforcerBullet"
Model.Parent = workspace.Trash
for i=1, 4 do
local Distance = (Tower.FireRay.Position - Target.HumanoidRootPart.Position).Magnitude
local Mid = (Tower.FireRay.Position + Target.HumanoidRootPart.Position) / 2
local Bullet = ReplicatedStorage.Assets.EnforcerBullet:Clone()
Bullet.CanCollide = false
Bullet.CanQuery = false
Bullet.CanTouch = false
Bullet.Massless = true
Bullet.Anchored = true
Bullet.Size = Vector3.new(0.064, 0.06, Distance)
warn(Mid)
warn(Tower.FireRay.Position, Target.HumanoidRootPart.Position)
Bullet.CFrame = CFrame.new(Mid)
Bullet.CFrame = CFrame.lookAt(Tower.FireRay.Position, Target.HumanoidRootPart.Position) * CFrame.Angles(math.rad(math.random(0,180)),math.rad(math.random(0,180)),math.rad(math.random(0,180)))
Bullet.Parent = Model
TweenService:Create(Bullet, TweenInfo.new(1), {Transparency = 1}):Play()
end
Try this 
sorry guys i give wrong code (it from a friend help me fix lol)
the cframe.new(0, 0, -Bullet.Size.Z/2) actully help me
The clean version for who need:
CFrame.new(Tower.FireRay.Position, Target.HumanoidRootPart.Position) * CFrame.Angles(math.rad(math.random(0, 25)), math.rad(math.random(0, 25)), math.rad(math.random(0, 25))) * CFrame.new(0, 0, -Bullet.Size.Z/2)
anyways thx @tienke
ig u from vietnam right?
1 Like
tienke
(tienke)
#6
Yea i am. I guess you from there too right?
1 Like
yep but i dont rly say im from vietnam cuz some reason
if u feel free can add my disco ctgvn123
system
(system)
Closed
#8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.