Hello, im making a cat stand script, So i was creating a move that freezes "time" but there is a problem, it only works with me and no players, if i use in a server with players it exhausts script execution time and the script ends, even if im using coroutines, nothing is happening. What the script does is make a part and size it while tweening its transparency, also it does a tween animation with the cat, then after the cat animation it goes back and freezes time for everyone while playing a sound, Now the problem is that the wait() exhausts it and the worst is that the sound doesn't remove and it gets removed after ending literally doing the animation lags the entire script, What could i possibly been doing wrong?
-- attack stands for can attack -- BTW makeSound just makes a new sound and returns it function StopTime() if StandVisible == true then attack = true character.Torso.Anchored = true local el = OriginalCFrame*CFrame.new(-2,4,4) local tw = game:GetService("TweenService") local info = TweenInfo.new(0.4,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0) local tween = tw:Create(StandWeld,info,{C0 = el*CFrame.Angles(math.rad(40),0,0)}) tween:Play() -- in this part the animation plays local part = Instance.new("Part") part.Size = Vector3.new(1,1,1) part.Shape = "Ball" part.Position = character.Torso.Position part.Anchored = true part.CanCollide = false part.FrontSurface = Enum.SurfaceType.Smooth part.TopSurface = Enum.SurfaceType.Smooth part.BackSurface = Enum.SurfaceType.Smooth part.LeftSurface = Enum.SurfaceType.Smooth part.RightSurface = Enum.SurfaceType.Smooth part.BottomSurface = Enum.SurfaceType.Smooth part.Parent = workspace local snd = makeSound(138086076) coroutine.resume(coroutine.create(function() local twe = game:GetService("TweenService") local abc = TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0) local twen = twe:Create(part,abc,{Size = part.Size+Vector3.new(50,50,50)}) twen:Play() end)) coroutine.resume(coroutine.create(function() local twe = game:GetService("TweenService") local abc = TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0) local twen = twe:Create(part,abc,{Transparency = 1}) twen:Play() twen.Completed:Wait() part:Destroy() end)) wait(0.4) tween = tw:Create(StandWeld,info,{C0 = el}) tween:Play() snd:Destroy() snd = makeSound(627730102,true) character.Torso.Anchored = false local timeF = true coroutine.resume(coroutine.create(function() for i,plr in pairs(game:GetService("Players"):GetPlayers()) do if plr ~= owner then coroutine.resume(coroutine.create(function() if plr.Character then for i,v in pairs(plr.Character:GetChildren()) do pcall(function() v.Anchored = true end) end end local conn local function aa(char) wait(0.2) for i,v in pairs(plr.Character:GetChildren()) do pcall(function() v.Anchored = true end) end end conn = plr.CharacterAdded:Connect(aa) repeat until timeF == false conn:Disconnect() if plr.Character then for i,v in pairs(plr.Character:GetChildren()) do pcall(function() v.Anchored = false end) end end end)) end end end)) wait(12) timeF = false snd:Stop() snd:Destroy() snd = makeSound(138086076) attack = false wait(1) snd:Destroy() end end
Oh my god im stupid, the problem was that i did
repeat until timeF == false
i should have done
repeat wait() until timeF == false
sorry!