Use :Wait() on the end of your tween.Completed event, and then return.
function CustomerClass:Walk()
print(self.Name, " walks")
local goal = {}
goal.Position = Vector3.new(-10.5, 0.5, 0.5)
local tween = TweenService:Create(self.Model, tweenInfo, goal)
tween:Play()
tween.Completed:Wait(function() -- use Wait() instead of Connect()
print(self.Name, "arrived")
return(whatever you want here) -- return something to the original function
end)
end
:Wait() is exactly like :Connect(), except that it ‘yields’ the thread until the event (here, the event is .Completed) fires. Instead of just connecting it when the .Completed event fires, it quite literally waits until the event fires, THEN runs the code.
Wrong for 100%
Wait method yields the current thread untill event is fired; Connect connects a function to a task scheduler of a connection.
That not even remotely close.
But Walk method is on module script and i use OOP,
let’s say when tween is over it will print “tween is completed”, so when i use this method on server script it will just print it but how will server know that tween was completed and not just the function
local SimpleCustomer = require(game.ReplicatedStorage.SimpleCustomer)
local newCustomer = SimpleCustomer.new("Челик", workspace.Customer)
newCustomer:Walk()