Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I fix lag when people first join my game?

Asked by 5 years ago
Edited 5 years ago

Whenever people join my game, it lags like crazy. The chat is broken, and people walk in place. From my research, it appears to be coming from a points saver script. However, this script is critical. and I need it. The model is a data saver. The other suspect is a leaderboard creator. At some point when there is a PlayerAdded function, it messes the whole server up. Please help!

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("GemSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
    local folder = Instance.new("Folder", plr)
    folder.Name = "leaderstats"
    local gems = Instance.new("IntValue", folder)
    gems.Name = "Obby Wins"


    gems.Value = ds1:GetAsync(plr.UserId) or 0
    ds1:SetAsync(plr.UserId, gems.Value)


    gems.Changed:connect(function()
        ds1:SetAsync(plr.UserId, gems.Value)
    end)


    end)

Another suspect:

game.Players.PlayerAdded:connect(function(p)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    stats.Parent = p

    local money = Instance.new("IntValue")
    money.Name = "Obby Wins" -- Change "Money" to anything you want to name it like "Cash"
    money.Parent = stats
end)

0
can you show us the script? Tyler090130 619 — 5y
0
Edited the question. @Tyler090130 happyhal75 32 — 5y

Answer this question