I have a script that creates a projectile on the server and that works fine. I want to use a heartbeat function on the client to move the projectile smoothly. This however does not work. The server projectile moves but the client one remains stationary. What should I do to fix this? The example code is pasted below:
RunService.Heartbeat:Connect(function(deltaTime)
if #workspace.RenderedProjectiles:GetChildren() > 0 then
for i, projectile in ipairs(workspace.RenderedProjectiles:GetChildren()) do
print(projectile.ProjectilePart.Value.Name)
local tweeninfo = TweenInfo.new(deltaTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local tween = TweenService:Create(projectile.PrimaryPart, tweeninfo, {CFrame = projectile.ProjectilePart.Value.PrimaryPart.CFrame})
tween:Play()
end
end
end)
workspace.Projectiles.ChildAdded:Connect(function(projectile)
task.wait()
if projectile:FindFirstChild(“Tween”) then
local clientProjectile = projectile:Clone()
local partsnumber = 0
for i, part in ipairs(clientProjectile:GetChildren()) do
if part:IsA(“BasePart”) then
part.Transparency = 0
partsnumber += 1
end
end
if partsnumber > 1 then
clientProjectile.PrimaryPart.Transparency = 1
end
clientProjectile.PrimaryPart.CFrame = projectile.PrimaryPart.CFrame
clientProjectile.Parent = workspace.RenderedProjectiles
Debris:AddItem(clientProjectile, projectile.Time.Value)
end
end)