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

Why edited by me script doesn't work?

Help me! I edited script for time played in game (leaderboard) by adding part of script for cash (again for leaderboard) and it's not working. (Script stops giving time played after 3 seconds.) I maked it in my new game (Again new game...) Mega Ultimate Obby (everyone knows it's in Roblox)

I want to make leaderboard with time played counter and with cash.

Script:

function onPlayerEntered(newPlayer)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    local cash = Instance.new("IntValue")             
	cash.Parent = stats 
	cash.Name = "Cash"
	cash.Value = 0
    local captures = Instance.new("IntValue")
    captures.Name = "Time Played"
    captures.Value = 0
    captures.Parent = stats
    stats.Parent = newPlayer
    wait(1)
    captures.Value=captures.Value+1
    wait(1)
    captures.Value=captures.Value+1
    wait(1)
    captures.Value=captures.Value+1

end

game.Players.ChildAdded:connect(onPlayerEntered)

And second local script that's in that script up (Not edited) (Idk what it does):

while wait(1) do
	game.Players.LocalPlayer.leaderstats["Time Played"].Value=game.Players.LocalPlayer.leaderstats["Time Played"].Value+1
end 

Original script (Not edited):

function onPlayerEntered(newPlayer)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    local captures = Instance.new("IntValue")
    captures.Name = "Time Played"
    captures.Value = 0
    captures.Parent = stats
    stats.Parent = newPlayer
	 wait(1)
	 captures.Value=captures.Value+1
	 wait(1) 
	 captures.Value=captures.Value+1
	 wait(1)
	 captures.Value=captures.Value+1
	 workspace.LinkedLeaderboard["Time Playing Counter"]:Clone().Parent=newPlayer.Backpack
	 workspace.LinkedLeaderboard["Time Playing Counter"]:Clone().Parent=newPlayer.StarterGear
end

game.Players.ChildAdded:connect(onPlayerEntered)

1 comment

0

english do how grammer right?

1 answer

✓ Accepted answer

i think i might have you answer

function onPlayerEntered(newPlayer)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    local cash = Instance.new("IntValue")             
    cash.Parent = stats 
    cash.Name = "Cash"
    cash.Value = 0
    local captures = Instance.new("IntValue")
    captures.Name = "Time Played"
    captures.Value = 0
    captures.Parent = stats
    stats.Parent = newPlayer
  while true do
	 
	 wait(1)
    captures.Value=captures.Value+1
    wait(1)
    captures.Value=captures.Value+1
    wait(1)
    captures.Value=captures.Value+1
end

end

game.Players.ChildAdded:connect(onPlayerEntered)

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