Client Rendering Projectiles Not Moving

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)

Sorry I do not know how to indent the text on the forum

I have deduced the problem down to this section of the script (the tweening of the model) but I can not figure out what is wrong with it?
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()

so the projectile is tweened, correct?

Yes I am tweening the primary part to the server’s projectile’s primary part. Using CFrames.

Is it anchored on the client or server?

On the server. I only clone it on the client

I had a system working where I made a separate tween for the client when it was created but I want it to hug the server projectile in case of client lag.

I solved the problem but thanks for helping!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.