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

Scripts and value changing?

Asked by 8 years ago
01for i,v in pairs(game.Players:GetPlayers()) do
02        Chillers =script.Parent.Chillers.Value
03        people = script.Parent.People.Value
04        Workers =script.Parent.Workers.Value
05        MyWorkers =script.Parent.MyWorkers.Value
06        people.Value=Chillers.Value+Workers.Value+MyWorkers.Value
07        v.PlayerGui.ScreenGui.Chillers.Text=("Unemployed: "..Chillers.Value)
08        v.PlayerGui.ScreenGui.Workers.Text=("Working: "..Workers.Value)
09        v.PlayerGui.ScreenGui.People.Text=("Total People: "..people.Value)
10        v.PlayerGui.ScreenGui.MyWorkers.Text=("Your Workers: "..MyWorkers.Value)
11    end

This is in a local script and the value is on default set onto 1 so correctly the code says "unemployed: 1" but when I change the value my self. (I manually go into the properties of the value and change the number without scripts.) The gui text remains as "unemploued: 1" Can I have help for this problem.

1 answer

Log in to vote
0
Answered by 8 years ago

Unless this in a player or one of their descendants (PlayerGui, ect.) try using a server script and put it in the ServerScriptService. The problem is that this only runs once the game starts, here would be a solution:

01function updategui()
02for i,v in pairs(game.Players:GetPlayers()) do
03        Chillers =script.Parent.Chillers.Value
04        people = script.Parent.People.Value
05        Workers =script.Parent.Workers.Value
06        MyWorkers =script.Parent.MyWorkers.Value
07        people.Value=Chillers.Value+Workers.Value+MyWorkers.Value
08        v.PlayerGui.ScreenGui.Chillers.Text=("Unemployed: "..Chillers.Value)
09        v.PlayerGui.ScreenGui.Workers.Text=("Working: "..Workers.Value)
10        v.PlayerGui.ScreenGui.People.Text=("Total People: "..people.Value)
11        v.PlayerGui.ScreenGui.MyWorkers.Text=("Your Workers: "..MyWorkers.Value)
12    end
13end
14 
15-- The following call the function updategui() whenever one of them is changed
16script.Parent.People.Changed:connect(updategui)
17script.Parent.Workers.Changed:connect(updategui)
18script.Parent.Chillers.Changed:connect(updategui)

Hope this helped.

Ad

Answer this question