When these lines Of code executes, It Just Frozen The game, in Studio It don’t happen, only in Roblox player
Script 1:
for i, player in game:GetService("Players"):GetPlayers() do
if player.Play.Value == true then
if player.Character then
game.ReplicatedStorage.Events.ChangePlayerCharacter:Fire(player)
player.PlayerGui.ItemInventory.Enabled = false
player.PlayerGui.Codes.Enabled = false
end
end
end
Script 2:
local function respawnPlayer(plr, Value)
local model = game.ReplicatedStorage.Car:FindFirstChild(CreateWeapon(Value)) or game.ReplicatedStorage.CarWeapon:FindFirstChild(CreateWeapon(Value))
local oldModel = plr.Character
local newModel = model:Clone()
newModel.Name = plr.Name
newModel.Parent = workspace.Cars
plr.Character = newModel
newModel:FindFirstChildOfClass("Humanoid").WalkSpeed *= CarLevel.GetSpeedMultiplierByExp(Value:GetAttribute("EXP"))
if plr.Potions.SpeedPotion.Value > 0 then
newModel:FindFirstChildOfClass("Humanoid").WalkSpeed *= 2
end
for i, Object in ipairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
local Clone = Object:Clone()
Clone.Parent = newModel
end
plr.Team = game.Teams.Cars
plr.Character:SetPrimaryPartCFrame(workspace.CarsSpawn.CFrame)
local DiedEvent = script.DiedEvent:Clone()
DiedEvent.Parent = newModel
DiedEvent.Enabled = true
local Gasoline = script.Gasoline:Clone()
Gasoline.Parent = newModel
Gasoline.Enabled = true
DebrisService:AddItem(oldModel, 0.2)
for i, Enchantment in Value:GetChildren() do
if Enchantment:IsA("BoolValue") then
local EnchantmentScript = script:FindFirstChild(Enchantment.Name)
if EnchantmentScript then
local Clone = EnchantmentScript:Clone()
Clone.Parent = newModel
Clone.Enabled = true
end
end
end
game.ReplicatedStorage.Events.ShowGasolineGUI:FireClient(plr, plr.UserId)
end