Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my auto leaderstat giver in server script service not work anymore?

game.Players.PlayerAdded:Connect(function(player)
	
	repeat wait(1) until game:IsLoaded()
	
	local prodVal = player.leaderstats.Production
	local coinVal = player.leaderstats["Ro-Coin"]
	local MPS = game:GetService("MarketplaceService")
	local id = 19564558
	
	while true do
		if MPS:UserOwnsGamePassAsync(player.UserId, id) or player.Name == "Apples002" or player.Name == "deatnumber61" or player.Name == "Nozazxe" or player.MembershipType == Enum.MembershipType.Premium then
		wait(2.5)
			coinVal.Value = coinVal.Value + prodVal.Value
		else
			if not MPS:UserOwnsGamePassAsync(player.UserId, id) then
			wait(5)
				coinVal.Value = coinVal.Value + prodVal.Value
			end
		end
	end
end)

I dont get any error or warning in the output. my game has suddenly stopped working cause of this, can someone help?

1 comment

0

Is there any errors or warnings in the output?

2 answers

Why are you putting that in a while true do loop without any cooldowns? Try while wait() do.

game.Players.PlayerAdded:Connect(function(player)

    repeat wait(1) until game:IsLoaded()

    local prodVal = player.leaderstats.Production
    local coinVal = player.leaderstats["Ro-Coin"]
    local MPS = game:GetService("MarketplaceService")
    local id = 19564558

    while wait() do
        if MPS:UserOwnsGamePassAsync(player.UserId, id) or player.Name == "Apples002" or player.Name == "deatnumber61" or player.Name == "Nozazxe" or player.MembershipType == Enum.MembershipType.Premium then
        wait(2.5)
            coinVal.Value = coinVal.Value + prodVal.Value
        else
            if not MPS:UserOwnsGamePassAsync(player.UserId, id) then
            wait(5)
                coinVal.Value = coinVal.Value + prodVal.Value
            end
        end
    end
end)

2 comments

0

It still does not work. And, i dont get any error in the output either.

0

It still does not work. And, i dont get any error in the output either.

solved this myself by removing the or arguement and making it its own if statement

This discussion is preserved as it was. New answers, comments, and votes are closed.