0

This is the code:

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

    money = Instance.new("IntValue")
    money.Name = "Money"
    money.Parent = leaderstats
    money.Value = 0
    ---------------------------------------------------------------------
    multiplier = Instance.new("IntValue")
    multiplier.Name = "Multiplier"
    multiplier.Parent = player
    multiplier.Value = 1.0
    ---------------------------------------------------------------------
    leaderstats.Parent = player
end) : 

workspace:WaitForChild("Upgrades"):WaitForChild("Upgrade_1"):WaitForChild("ClickDetector").MouseClick:Connect(function(player)
    workspace:WaitForChild("Upgrades"):WaitForChild("Upgrade_1"):WaitForChild("ClickDetector"):Destroy() -- Removes ClickDetector
    local money = player:WaitForChild("leaderstats"):WaitForChild("Money")
    ---------------------------------------------------------------------    ---------------------------------------------------------------------
    while True wait(0.025) do
        local currentMultiplier = player:WaitForChild("Multiplier").Value
        money.Value = money.Value + (1.0 * currentMultiplier)  
    end
end)

The problem is that when I change the multiplier.Value in Roblox Studio, it doesn't change in the code. However, when I change it in the code, it works fine. I don't know how to get the code to update when I change the variable manually in Roblox Studio.

One of my theories is that money.Value is not checking if the variable changed while the loop is running.

5
  • What do you mean by "when I change the multiplier.value"? Is multiplier an IntValue in your workspace? If it is, when is it created? Where is it located? I have a suspicion as to what's happening, but I can't be sure without a little more information.
    – Andrew Yim
    Commented Jun 24 at 2:29
  • when you use studio test you dont have network ownership over the the IntValue so it wont replicate. you'll have to switch over to server simulation and change it while inside server simulation: create.roblox.com/docs/studio/testing-modes#clientserver-toggle
    – Yorick
    Commented Jun 24 at 8:18
  • @LTyrone Why did you reject Andrew Yim's edit only to make the exact same change yourself in your own edit? Commented Jun 25 at 3:40
  • @JosephSible-ReinstateMonica - suggested edit != my edit.
    – L Tyrone
    Commented Jun 25 at 19:32
  • @LTyrone Your edit was the entirety of the suggested edit plus other stuff, so you should have done "Improve edit" rather than "Reject and edit". Commented Jun 25 at 23:27

0

Browse other questions tagged or ask your own question.