THIS WHOLE SCRIPTS USE TO WORK but when i started using coroutine on the bottom it started to crash roblox studio but when i remove the co routines it works fine, so i have no clue what to do now
local play = game:GetService("Players")
local plr = play.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local rend = game:GetService("RunService")
local rep = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local debri = game:GetService("Debris")
local teams = game:GetService("Teams").killer
local tween = game:GetService("TweenService")
local cas = game:GetService("ContextActionService")
plr.Team = teams
local speed = TweenInfo.new(1,Enum.EasingStyle.Linear)
local max = tween:Create(hum,speed,{WalkSpeed = 60})
local wallgit = rep.remotes.wallhit
local wallhitis = false
local qcd = false
local animator = hum:WaitForChild("Animator")
local hit = script:WaitForChild("attack")
local hitting = animator:LoadAnimation(hit)
local q = script:WaitForChild("q ability")
local locate = animator:LoadAnimation(q)
local start = script:WaitForChild("start")
local starttter = animator:LoadAnimation(start)
local running = script:WaitForChild("e run")
local runner = animator:LoadAnimation(running)
local wall = script:WaitForChild("wallhit")
local wallhit = animator:LoadAnimation(wall)
runner.Looped = true
local debounce = false
local hitbox = rep.remotes:WaitForChild("Event")
local gottagofast = rep.remotes:WaitForChild("goback")
local charge = rep.remotes:WaitForChild("Charge")
local Comp = require(rep.service.ModuleScript)
local tableUtils = require(rep.service.TableUtils)
local camfixed = false
local hitpos = {}
local damage = 10
local x = 5
local y = 5
local z = 7
local function gottafast()
hitpos = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-6)
gottagofast:FireServer(hitpos)
print(qcd)
end
rend.RenderStepped:Connect(gottafast)
uis.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce then return end
hum.WalkSpeed *= 1.5
debounce = true
hitting:Play()
hitbox:FireServer(damage, x, y, z)
wait(0.5)
hum.WalkSpeed /= 1.5
wait(0.4)
debounce = false
end
end)
local function cooldown()
while qcd == true do
wait(10)
qcd = false
end
end
uis.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Q then
if debounce then return end
if qcd then return end
hum.WalkSpeed = 0
debounce = true
locate:Play()
for i, Player in pairs(play:GetPlayers()) do
if Player ~= play.LocalPlayer then
local Character = Player.Character
if Character then
if Character:FindFirstChildWhichIsA("Highlight") then
Character:FindFirstChildWhichIsA("Highlight"):Destroy()
end
if Player.Team ~= play.LocalPlayer.Team then
local Highlight = Instance.new("Highlight")
Highlight.FillColor = Color3.new(1)
Highlight.Parent = Character
wait(0.9)
qcd = true
wait(3)
game.Debris:AddItem(Highlight,1)
debounce = false
task.spawn(cooldown)
end
end
end
end
end
end)
local keeeeeep = nil
local function kepmoving()
if camfixed then
hum:Move(Vector3.new(0,0,-1), true)
keeeeeep = rend.RenderStepped:Connect(kepmoving)
end
end
local corp = coroutine.wrap(kepmoving)
local content = nil
local function coop()
if debounce then return end
camfixed = true
corp()
debounce = true
hum.WalkSpeed = 0
starttter:Play()
wait(0.5)
charge:FireServer(damage, x, y, z)
runner:Play()
max:Play()
max.Completed:Wait()
task.wait(5)
keeeeeep:Disconnect()
debounce = false
hum.WalkSpeed = 16
runner:Stop()
end
cas:BindAction("charge", coop, true, Enum.KeyCode.E)
local cooper = coroutine.create(coop)
wallgit.OnClientEvent:Connect(function()
debounce = true
coroutine.close(cooper)
coroutine.close(corp)
runner:Stop()
max:Remove()
wallhitis = true
hum.WalkSpeed = 0
wallhit:Play()
wait(1)
hum.WalkSpeed = 16
wallhitis = false
debounce = false
end)
corp() is a wrapped coroutine, not a coroutine thread. coroutine.wrap returns a function, not a coroutine thread, so you can’t close it with coroutine.close(). You’re calling corp() repeatedly, and kepmoving connects kepmoving again and again recursively, leading to infinite RenderStepped connections… which causes studio crash due to runaway connections.
Best guess without being able to work with this script in game.
Good luck
local play = game:GetService("Players")
local plr = play.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local rend = game:GetService("RunService")
local rep = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local debri = game:GetService("Debris")
local teams = game:GetService("Teams").killer
local tween = game:GetService("TweenService")
local cas = game:GetService("ContextActionService")
plr.Team = teams
local speed = TweenInfo.new(1,Enum.EasingStyle.Linear)
local max = tween:Create(hum,speed,{WalkSpeed = 60})
local wallgit = rep.remotes.wallhit
local wallhitis = false
local qcd = false
local debounce = false
local camfixed = false
local animator = hum:WaitForChild("Animator")
local hit = script:WaitForChild("attack")
local hitting = animator:LoadAnimation(hit)
local q = script:WaitForChild("q ability")
local locate = animator:LoadAnimation(q)
local start = script:WaitForChild("start")
local starttter = animator:LoadAnimation(start)
local running = script:WaitForChild("e run")
local runner = animator:LoadAnimation(running)
local wall = script:WaitForChild("wallhit")
local wallhit = animator:LoadAnimation(wall)
runner.Looped = true
local hitbox = rep.remotes:WaitForChild("Event")
local gottagofast = rep.remotes:WaitForChild("goback")
local charge = rep.remotes:WaitForChild("Charge")
local Comp = require(rep.service.ModuleScript)
local tableUtils = require(rep.service.TableUtils)
local hitpos = {}
local damage = 10
local x = 5
local y = 5
local z = 7
local function gottafast()
hitpos = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-6)
gottagofast:FireServer(hitpos)
end
rend.RenderStepped:Connect(gottafast)
uis.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce then return end
hum.WalkSpeed *= 1.5
debounce = true
hitting:Play()
hitbox:FireServer(damage, x, y, z)
wait(0.5)
hum.WalkSpeed /= 1.5
wait(0.4)
debounce = false
end
end)
local function cooldown()
wait(10)
qcd = false
end
uis.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Q then
if debounce or qcd then return end
hum.WalkSpeed = 0
debounce = true
locate:Play()
for _, Player in pairs(play:GetPlayers()) do
if Player ~= plr then
local Character = Player.Character
if Character and Player.Team ~= plr.Team then
local old = Character:FindFirstChildWhichIsA("Highlight")
if old then old:Destroy() end
local h = Instance.new("Highlight")
h.FillColor = Color3.new(1)
h.Parent = Character
game.Debris:AddItem(h,1)
end
end
end
wait(0.9)
qcd = true
wait(3)
debounce = false
task.spawn(cooldown)
end
end)
local keepMove
local function kepmoving()
hum:Move(Vector3.new(0,0,-1), true)
end
local function coop(_, state, _)
if state ~= Enum.UserInputState.Begin then return end
if debounce then return end
camfixed = true
keepMove = rend.RenderStepped:Connect(kepmoving)
debounce = true
hum.WalkSpeed = 0
starttter:Play()
wait(0.5)
charge:FireServer(damage, x, y, z)
runner:Play()
max:Play()
max.Completed:Wait()
task.wait(5)
if keepMove then keepMove:Disconnect() end
debounce = false
hum.WalkSpeed = 16
runner:Stop()
end
cas:BindAction("charge", coop, true, Enum.KeyCode.E)
wallgit.OnClientEvent:Connect(function()
debounce = true
if keepMove then keepMove:Disconnect() end
runner:Stop()
max:Cancel()
wallhitis = true
hum.WalkSpeed = 0
wallhit:Play()
wait(1)
hum.WalkSpeed = 16
wallhitis = false
debounce = false
end)
You have found the issue already, but for the future, I have found it beneficial to change the ScriptTimeoutLength setting in Studio to 5 seconds to prevent Studio from freezing for a minute (or longer) when a script holds everything up.