This is the script for my game, When I try to test it out it lags like crazy. I used Fraps and it said I had 0 FPS. Is there something in the script making it lag and is there something I could do to prevent it?
game.Players.PlayerAdded:connect(function(newplyr) local lb = Instance.new("IntValue", newplyr) local Wins = Instance.new("IntValue") script.Players.Value = script.Players.Value+1 Wins.Parent = lb end) game.Players.PlayerRemoving:connect(function(newplyr) script.Players.Value = script.Players.Value-1 end) while true do local rr = math.random(1,1) if script.Players.Value >= 2 then--Players needed if rr == 1 then target = CFrame.new(0, 3, 0) for i, player in ipairs(game.Players:GetChildren()) do if player.Character and player.Character:FindFirstChild("Torso") then player.Character.Torso.CFrame = target + Vector3.new(0, 0, 0) end end game.Lighting.Safe:clone().Parent = workspace local h = Instance.new("Hint", workspace) h.Text = "Spread Out!" wait(3) Time = 5 repeat Time = Time-1 h.Text = "Time left to spread out: "..Time.."" wait(1) until Time <= 0 h:remove() workspace.Safe:remove() game.Lighting.Spleef_Arena:clone().Parent = workspace Time = 60 repeat Time = Time-1 h.Text = "Time left: "..Time.."" wait(1) until Time <= 0 h.Text = "Time's up!" game.Workspace.Spleef_Arena:remove() wait(4) h:remove() end else local h = Instance.new("Hint", workspace) plyrs = 2-script.Players.Value if plyrs == 1 then h.Text = "You need "..plyrs.." more player!" else h.Text = "You need "..plyrs.." more players!" end end end
I think IcyArticuno is right. It's executing all that code so fast that your game is lagging big time