Hello! Ive made this function and whenever i call it it immediately goes onto the next thing in the code.
local function Mainanimation(AnimName, looped, bpm)
Loop = AnimName
local Timeing = 0
local CurrentAnimation = 1
local CurrentSkin = "Default"
local currentAnimation = animations[CurrentSkin] or nil
if currentAnimation ~= nil then
local animation = currentAnimation[AnimName] or nil
if animation ~= nil then
local Runstepped
Runstepped = runService.RenderStepped:Connect(function(timeSince)
Timeing += timeSince
if Loop ~= AnimName then
Runstepped:Disconnect()
--print("Err")
return true
end
if animation[CurrentAnimation] ~= nil then
offset = 60/bpm
if offset <= Timeing then
PlayAnimation(animation[CurrentAnimation]['id'])
CurrentAnimation += 1
Timeing = 0
end
else
Runstepped:Disconnect()
--print("Done", Timeing)
return true
end
end)
end
end
end
local function Giveanimation(AnimName, looped, bpm)
if looped and Loop ~= AnimName then
Loop = AnimName
while Loop == AnimName do
local ret
ret = Mainanimation(AnimName, looped, bpm)
task.wait(bpm/60)
end
elseif Loop ~= AnimName then
Loop = AnimName
Mainanimation(AnimName, Loop, bpm)
end
end
What can i do to make this function synchronous? im thinking it probably has something to do with the renderstepped?