Tweening non humanoid models in client doesn't work

  1. What do you want to achieve? I have a system where i tween the enemies to a waypoint

  2. What is the issue? Enemies doesn’t move, instead they rotate?
    Captura de pantalla 2024-08-29 131957

  3. What solutions have you tried so far? I don’t know how to fix this, my first time doing something like this

local script in starterplayerscripts:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Events = ReplicatedStorage:WaitForChild("Events")
local remoteEvents = Events:WaitForChild("Remotes")
local moveEnemyEvent = remoteEvents:WaitForChild("MoveEnemy")

moveEnemyEvent.OnClientEvent:Connect(function(enemy, enemyStats, map)
	local speed = enemyStats["Speed"]
	local waypoints = map.Waypoints:GetChildren()

	local startTime = tick()
	local serverTimeNow = workspace:GetServerTimeNow()
	local timeOffset = (startTime - serverTimeNow)
	local distanceOffset = (speed * timeOffset)

	for i = 1, #waypoints do
		local waypoint = waypoints[i]
		local distance = (enemy.PrimaryPart.Position - waypoint.Position).Magnitude
		local walkSpeed = distance / speed

		local tweenInfo = TweenInfo.new(walkSpeed, Enum.EasingStyle.Linear)
		local tweenGoal = {Position = waypoint.Position}
		local tween = TweenService:Create(enemy.PrimaryPart, tweenInfo, tweenGoal)

		tween:Play()
		tween.Completed:Wait()
--		enemy.Config.MovingTo.Value = i
	end
end)

enemy module in serverscriptservice inside of a server script:

function enemy.Move(enemy, map)
	local enemyStats = require(enemyModuleAccess:FindFirstChild(enemy.Name))
	moveEnemyEvent:FireAllClients(enemy, enemyStats, map)
end
4 Likes

Note: if you use methoods such as move, use semicolon instead of dot, it looks better and also helps when OOP

Note2: Also why you tween variable? you can do for loop that do the same and you will have more control over it + more performance

Problem is that those characters have motor6D ect. you should anchor them first to move them, instead they will bounce and rotate

If i anchor them, i cannot set the Network Ownership to nil

this is what you can do, use this tutorial to anchor and tween the enemies on the client.

then you can tween an invisable part at the same time on the server, which you can then use to make towers attack the enemy.

this makes the enemies smooth on the client, while still alowing the server to handler hit detection and such

? why would you need network ownership over non humanoid characters?

oh yeah i completely forgot that i don’t need to do that on non humanoid characters, my bad, for now ill watch what @Bikereh said

This didnt work, also this is only happening when i do this in the client through a remote event, but when i made it in the module script in serverscriptservice it works but i want good performance so i dont want to do that