Hi.
So essentially, I want this script to change the integer value in ReplicatedStorage, which would then change every other SurfaceGui’s TextLabel, but unfortunately the script does not change the value.
local rep = game:GetService("ReplicatedStorage")
local main = script.Parent.Parent
local btn = script.Parent
local pos = main.bpos
local Av = rep:WaitForChild("GrpA")
local Bv = rep:WaitForChild("GrpB")
local Cv = rep:WaitForChild("GrpC")
local gAA = main.A
local gBB = main.B
local gCC = main.C
local nAv = Av.Value
local nBv = Bv.Value
local nCv = Cv.Value
local gA = "A-"
local gB = "B-"
local gC = "C-"
btn.MouseButton1Click:Connect(function()
print("Function Started")
local x = Av.Value - 1
local newpos = nAv - x
local y = Bv.Value - 1
local newposB = nBv - y
local z = Cv.Value - 1
local newposC = nCv - z
if Av.Value > 0 then
pos.Text = "Your boarding position: "..gA..newpos
Av.Value -= 1
gAA.Text = "Group A: "..Av.Value
else
Av.Value = 0
gAA.Text = "Group A: "..Av.Value
if Bv.Value > 0 then
pos.Text = "Your boarding position: "..gB..newposB
Bv.Value -= 1
gBB.Text = "Group B: "..Bv.Value
else
Bv.Value = 0
gBB.Text = "Group B: "..Bv.Value
if Cv.Value > 0 then
pos.Text = "Your boarding position: "..gC..newposC
Cv.Value -= 1
gCC.Text = "Group C: "..Cv.Value
else
print("All boarding groups empty!")
Cv.Value = 0
gCC.Text = "Group C: "..Cv.Value
pos.Text = "All boarding groups empty!"
end
end
end
local finalBoardingPosition
if Av.Value > 0 then
finalBoardingPosition = "A-"..newpos - 1
else
if Bv.Value > 0 then
finalBoardingPosition = "B-"..newposB - 1
else
if Cv.Value > 0 then
finalBoardingPosition = "C-"..newposC - 1
end
end
end
local final = script.Parent.Parent.BoardingPosition
final.Value = finalBoardingPosition
print(final.Value)
end)
Any help is appreciated, thanks!