You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
So when you call a function, my understanding is that you call the function and then the function runs and then once it finished running the next instruction would be be the line beneath the call. -
What is the issue? Include screenshots / videos if possible!
Look below; the two code samples and my writing. I want to understand how are functions meant to work like. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes, but I couldn’t find any.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local function alwaysmove()
wait(25)
print("jpo")
end
local function ytouch(part)
alwaysmove()
wait(5)
print("last jpo by 5")
end
ytouch()
As expected, when the code runs it waits 25 seconds print “jpo” and then waits 5 seconds to print “last jpo by 5”. This is normal understanding of how I expect execution of functions supposed to be like.
local function loopmove()
while true do
local goal = tween:Create(obj, TweenInfo.new(5)
, {Position = Vector3.new(0,0,0),
Color = Color3.new(0, 1, 0)})
goal:Play()
local secondgoal = tween:Create(obj, TweenInfo.new(3)
, {Position = Vector3.new(0,10,0),
Color = Color3.new(1, 0.364706, 0.533333)})
secondgoal:Play()
end
end
function Movement(part)
print(part.Name)
print(part.Parent:FindFirstChild("Humanoid"))
if part.Parent:FindFirstChild("Humanoid") then
loopmove()
print("truthers?")
end
end
DO NOT RUN THIS CODE. WILL HANG INDEFINITELY
emphasis this part
goal:Play()
I expect goal:Play() to finish executing then for the second goal to start playing with secondgoal:Play(). However, unexpectedly, goal:Play() doesn’t finish executing and immediately runs to the next line of code