It works good. But the thing is, it gives me this error after it runs and stops: 'Unable to resume dead coroutine'
Is there a fix?
Spectate = coroutine.wrap(function()
local plrs
while script.Parent.Parent.Spectating.Value do
print(math.random(1,10))
wait()
local plrs = GatherPlayers()
if not script.Parent.Parent.Spectating.Value then
cam.CameraSubject = p.Character.Humanoid
coroutine.yield()
end
end
end)
script.Parent.MouseButton1Click:connect(function()
game.Players.LocalPlayer.PlayerGui.Assets.Sounds.Click:Stop()
game.Players.LocalPlayer.PlayerGui.Assets.Sounds.Click:Play()
if not p.Character.Humanoid:FindFirstChild("Alive") then
script.Parent.Parent.Spectating.Value = not script.Parent.Parent.Spectating.Value
script.Parent.Parent.SpectateFrame.Visible = not script.Parent.Parent.SpectateFrame.Visible
if script.Parent.Parent.Spectating.Value then
coroutine.resume(Spectate())
end
end
end) |