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

IntValue doesn't change in the output?

Asked by 3 years ago

So I have local Folder = Instance.new("Folder") Folder.Name = "leaderstats" Folder.Parent = player local Level = Instance.new("IntValue") Level.Name = "Level" Level.Parent = Folder

local qoroutine = coroutine.create(function() while true do print(Level.Value) wait(.1) end end) coroutine.resume(qoroutine)

Then i go to the folder and change the value of level, and it doesn't change in the output?

1 answer

Log in to vote
0
Answered by 3 years ago

The script is fine, the reason that your IntValue isn't changing is because you aren't changing the value on the server. If you change a value on a client, it doesn't replicate to the server. This is to prevent exploiters, let's say a hacker sets their cash to 10000000, the server would still see it as 0. To fix this you could either increment the value

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
    local Folder = Instance.new("Folder") 
    Folder.Name = "leaderstats" 
    Folder.Parent = player 

    local Level = Instance.new("IntValue") 
    Level.Name = "Level" 
    Level.Parent = Folder

    local qoroutine = coroutine.create(function() 
        while true do
            Level.Value += 1 -- Incrementing the value every 0.1 seconds (10/sec)
            print(Level.Value) 
            wait(.1)
        end 
    end)
    coroutine.resume(qoroutine)
end)

or you could just do this and change the value on the server

0
thank you very much, i was really confused transparens 2 — 3y
Ad

Answer this question