function onClicked()
local Cannon = script.Parent
local Barrel = Cannon.Barrel
local Fireball = game.ServerStorage.FireBall
local fireballCopy = Fireball:Clone()
fireballCopy.Parent = game.Workspace
fireballCopy.Position = Barrel.Position
fireballCopy.Velocity = Vector3.new(100,0,0)
end
script.Parent.Parent.Part.ClickDetector.MouseClick:connect(onClicked)
I want to make these appear at the same place on the Y axis (where the barrel is) and same place on the Z axis but I want to make them appear semi randomly near the barrel on the x axis I tried using something like
function onClicked()
local Cannon = script.Parent
local Barrel = Cannon.Barrel
local Fireball = game.ServerStorage.FireBall
local fireballCopy = Fireball:Clone()
fireballCopy.Parent = game.Workspace
fireballCopy.Position = CFrame.new(math.random(0.1, 0.2), Barrel.Position, Barrel.Position)
fireballCopy.Velocity = Vector3.new(100,0,0)
end
script.Parent.Parent.Part.ClickDetector.MouseClick:connect(onClicked)
But I don't really know how to use CFrame and it didn't work any help would be appreciated.

1 comment
Thanks