I am trying to move a projectile model by tweening the primary part but instead of moving the whole model it just moves the primary part.
local direction = (tip.Position - hit.p).Magnitude
local spellObject = game:GetService("ReplicatedStorage"):WaitForChild("WandModel"):Clone()
spellObject.Parent = workspace
spellObject:SetPrimaryPartCFrame(CFrame.new(tip.Position, hit.p))
-- Fire spellObject in direction of mouse
local tweenInfo = TweenInfo.new(
direction * SPEED,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local goal = {
CFrame = hit
}
local tween = TweenService:Create(spellObject.PrimaryPart, tweenInfo, goal)
tween:Play()
-- Damage a player when the spell object hits them
-- and then destroy the object
connection = spellObject.PrimaryPart.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and humanoid.Parent.Name ~= player.Name then
humanoid:TakeDamage(DAMAGE)
spellObject:Destroy()
connection:Disconnect()
end
end)
