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

Leaderstats script works in studio but doesn't work in my Roblox game?

Asked by 6 years ago

Please help. This is like the tenth time I've posted this question and twice it has been wrongfully moderated by this joke of a moderation team and 0 of the times the question has correctly been answered. (If this is taken down before it has been answered it will be reposted. Just sayin) Anyway. This is one of my scripts. It is supposed to take the value of Videos and add it to the value of Views every 2 minutes. It works perfectly in Studio, but not the game it is on. I have tried using WaitForChild, doesn't work still. If anyone wants to see the game it is on, here it is: https://web.roblox.com/games/1300877434/OPEN-Be-a-YouTuber-ALPHA#!/about I don't know if that will help answer my question or not, but just in case I put it there. Better to be safe than sorry. I tried putting 'print' messages every few lines and they all work in the server so the script runs fine, it just doesn't work in the server despite working in Studio. I also tried using while wait(120) do in the first line, but I tried using while true do to see if that would make a difference (it didn't). Here is my script:

print("The script runs!")
while true do
    wait(5)
for _,Player in pairs(game.Players:GetPlayers()) do
    print("Line 2 works!")
local leaderstats = Player:WaitForChild("leaderstats")
local subs = leaderstats:WaitForChild("Subscribers")
local Views = leaderstats:WaitForChild("Views")
local Videos = leaderstats:WaitForChild("Videos")
print("We have defined the values!")
if subs.Value <= 10 then
Views.Value = Views.Value + Videos.Value
print("The script ran but it didn't work!")
end
end
end


Remember, the SCRIPT'S PRINT VALUES WORK IN THE SERVER and the SCRIPT WORKS FOR ITS INTENDED PURPOSE IN STUDIO.

0
This is the second time you've posted this on one of my posts. I don't need to know the script is wrong, I know that very well already. sesamert16 31 — 6y
0
Why are you using a while loop? User#5423 17 — 6y
0
take out the while loop that may be your problem, in fact I think it is. FlippinAwesomeCrew 62 — 6y
0
I want the loop to run infinitely. Why not use a while loop? I think that would be the best thing to use. What would I use instead? sesamert16 31 — 6y

Answer this question