Ad
Log in to vote
0

IntValue doesn't change in the output?

Asked by 10 days 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 10 days 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 — 10d
Ad

Answer this question