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

Leaderstats script works well in Studio, but not ingame? (TENTH TIME. HELP)

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, ALL OF THE PRINT COMMANDS RUN IN THE SERVER, and the SCRIPT WORKS FOR ITS INTENDED PURPOSE IN STUDIO PUT NOT THE SERVER.

0
have you already created a leaderstats in another script? JakePlays_TV 97 — 6y
0
when a script only works in studio that means there something wrong with it ootheboss 32 — 6y
0
are there any lines under anything? ootheboss 32 — 6y
0
go to the server, press F9 and tell me if it gives any error (check both client and server) User#20388 0 — 6y
View all comments (3 more)
0
Jake - Yes sesamert16 31 — 6y
0
oo - well obviously, and no, redcommander - no, the only things i see are my print commands sesamert16 31 — 6y
0
actually, i just double checked and it says "leaderstats is not a valid member of players" but i don't think its from this script (it didn't say which script it was from) sesamert16 31 — 6y

Answer this question