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

Why doesn't it add leaderstats with a Server Script?

So I'm making a live event for new years and I wanna give my players that were there on the new years some Minutes spent but It won't add why?, And plus its a Server Script

local timeToStart = 1609416000

local player = game.Players

local tree = game.Workspace.LifeEvent.LifeTree

local timeToStop = 1609480800

function liveEvent()
	
end

while wait(1) do
	local timeNow = os.time()
	
	if timeNow >= timeToStart then
		while true do
			tree.Size = tree.Size * 2
			player.leaderstats.Minutes.Value = player.leaderstats.Minutes.Value + 500
		end
		print("Start the Live Event")
		liveEvent()
		break
	else
		print("Time till live event: "..(timeToStart-timeNow).." seconds")
	end
end

3 comments

0

do you mean time played?

0

or time until new years/event start

0

I made leaderstats that every minute you get 1 minute

1 answer

game.Players gives you all the players, not the player playing. I made it go through all the players and give them minutes.

local players = game.Players
local timeToStart = 1609416000
local timeToStop = 1609480800
local tree = workspace.LifeEvent.LifeTree

function liveEvent()
	
end

while wait(1) do
	local timeNow = os.time()
	if timeNow >= timeToStart then
		for _, player in pairs(players:GetPlayers()) do
			player.leaderstats.Minutes.Value = player.leaderstats.Minutes.Value + 500
		end
		tree.Size = tree.Size * 2
		print("Start the Live Event")
		liveEvent()
		break
	else
		print("Time till live event: "..(timeToStart-timeNow).." seconds")
	end
end

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