This script is supposed to take the value of Views, divide it by 35, and have the quotient be the value of Subscribers. It works in Studio but not in my game. I have tried many things: using WaitForChild, not using anything, putting a wait period of 5 minutes at the beginning of the script (what you see here) lots of different things. This is the script:
wait(300) dividedby = 35 while true do wait(1) for _,player in pairs(game.Players:GetPlayers()) do if player:FindFirstChild("leaderstats")then player.leaderstats.Subscribers.Value = ( player.leaderstats.Views.Value / dividedby ) end end end
Someone on my last post asked for the script that creates the leaderstats, so here you go:
local playerLeaderstats = {} game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local subscribers = Instance.new("IntValue") subscribers.Name = "Subscribers" subscribers.Value = 0 subscribers.Parent = leaderstats local views = Instance.new("IntValue") views.Name = "Views" views.Value = 0 views.Parent = leaderstats local videos = Instance.new("IntValue") videos.Name = "Videos" videos.Value = 0 videos.Parent = leaderstats local money = Instance.new("IntValue") money.Name = "Money" money.Value = 0 money.Parent = leaderstats end)
dividedby = 35 while true do wait(1) for _,player in pairs(game.Players:GetPlayers()) do if player:FindFirstChild("leaderstats")then player.leaderstats:WaitForChild('Subscribers').Value = ( player.leaderstats.Views.Value / dividedby ) end end end
this should work. Your Game was probably still loading the leaderstats in the game while the other script was trying to change a value that is not there.