I want to make a GUI that will count how many players are sitting in a truck for my Story game's lobby. When I step on a button, it will put me in the truck but I don't know how to make the number larger on the SurfaceGUI I made according to how many people are sitting in the truck. Here is what I have done so far
01 | --Variables |
02 | local leftValue = game.Workspace.LeftRoad.Truck.Value --To see if the truck exists in the Workspace |
03 | local CounterLeft = game.Workspace.Counters.LeftCounter.SurfaceGui.Count.Text |
04 | local LeftCountVal = game.Workspace.LeftRoad.Count.Value |
05 | local buttonLeft = game.Workspace.Entries.LeftEnter --Button when touched, makes you enter the truck |
06 |
07 | --Script to count players in the truck |
08 | if leftValue = = true then |
09 | buttonLeft.Touched:Connect( function (plr) |
10 | if plr.Parent:FindFirstChild( "Humanoid" ) then |
11 | LeftCountVal = LeftCountVal + 1 |
12 | wait( 0.5 ) |
13 | CounterLeft = LeftCountVal |
14 | end |
15 | end ) |
16 | end |
So I want the text on the SurfaceGui to be the same as the text on the IntValue (Which is the variable "LeftCountVal") some help would be greatly appreciated!
You are storing game.Workspace.Counters.LeftCounter.SurfaceGui.Count.Text
and game.Workspace.LeftRoad.Count.Value
in a Variable. But when you try to change it it ONLY changes that variable, NOT the property itself.
.PropertyName
after the Variable.01 | --Variables |
02 | local leftValue = game.Workspace.LeftRoad.Truck.Value --To see if the truck exists in the Workspace |
03 | local CounterLeft = game.Workspace.Counters.LeftCounter.SurfaceGui.Count |
04 | local LeftCountVal = game.Workspace.LeftRoad.Count |
05 | local buttonLeft = game.Workspace.Entries.LeftEnter --Button when touched, makes you enter the truck |
06 |
07 | --Script to count players in the truck |
08 | if leftValue = = true then |
09 | buttonLeft.Touched:Connect( function (plr) |
10 | if plr.Parent:FindFirstChild( "Humanoid" ) then |
11 | LeftCountVal.Value = LeftCountVal.Value + 1 |
12 | wait( 0.5 ) |
13 | CounterLeft.Text = LeftCountVal.Value |
14 | end |
15 | end ) |
16 | end |