Values updating for one script and not the other

Explain

I have 2 LOCAL SCRIPTS, both scripts have the SAME code. What I want to happen is the following:
Use the two values Debo and CurTab almost like global variables that can be accessed from any other local script. Debo is a BOOL being short for debounce, will be set to true when I want to activate a “cooldown”. CurTab is a STRING value, and the value of it is supposed to change to whichever button I clicked on.

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.5)
local GoalOpen = {BackgroundColor3 = Color3.fromRGB(238, 238, 238), ImageColor3 = Color3.fromRGB(56, 56, 56)}
local GoalClose = {BackgroundColor3 = Color3.fromRGB(56, 56, 56), ImageColor3 = Color3.fromRGB(238, 238, 238)}

local CurTab = script.Parent.Parent.CurrentTab.Value
local Debo = script.Parent.Parent.Debounce.Value

local function TweenButton(inst, goal)
	local CreateTween = TweenService:Create(inst, tweenInfo, goal)
	CreateTween:Play()
end

script.Parent.Activated:Connect(function()
	print("--------------------")
	print("Start:"..CurTab)
	if not Debo and CurTab == "" then
		Debo = true
		CurTab = script.Parent.Name
		print("Selecting")
		TweenButton(script.Parent, GoalOpen)
		wait(1)
		Debo = false
	elseif not Debo and CurTab == script.Parent.Name then
		Debo = true
		CurTab = ""
		print("Unselecting")
		TweenButton(script.Parent, GoalClose)
		wait(1)
		Debo = false
	elseif not Debo and CurTab ~= script.Parent.Name and CurTab ~= "" then
		Debo = true
		CurTab = script.Parent.Name
		print("Desellecting others")
		for i, v in pairs(script.Parent.Parent) do
			if v.Name == CurTab then
				TweenButton(v, GoalClose)
			end
		end
		TweenButton(script.Parent, GoalOpen)
		wait(1)
		Debo = false
	end
	print("End:"..CurTab)
	print("--------------------")
end)

Here is what happends when I click the HOME button

image

Here is what happends when I click the LOCAL button WHILE the HOME button is selected

image

Conclusion

So overall, the two local scripts are able to read and write to the value but when I try to read it from another local script, it doesn’t read a value, even if one script does read a value.
image

1 Like
local CurTab = script.Parent.Parent.CurrentTab
local Debo = script.Parent.Parent.Debo

Use the above instead, and each time you call them, put .Value at the end.

I dont need to tho right? Cause I set CurTab = script.Parent.Parent.CurrentTab.Value

It won’t re-initiate, as you’d call it once, but the value’d never be set again.

Let’s say you have a BoolValue called “Bool”, the value is set to true, and it’s defined with a .Value.

local Bool = script.Bool.Value

If we print it, it’d print true.
If we try to set it to false, the instance doesn’t change, however the variable does.

1 Like

thank you, I had no clue values worked like that