Not changing bool value

Hello Developers, I am making an arch-type system for a football game. I’m having the problem where when the Selected-Poss value is either home or away none of the Home or Away Bool Values the Bools just stay neutral. They don’t check or uncheck. Please help.

Code:

local Player = game.Players.LocalPlayer
local Character = Player.Character
local ArchFile = game.ReplicatedStorage:WaitForChild('ArchData')
local HPos = ArchFile.OFF.SelectedPos
local APos = ArchFile.DEF.SelectedPos
local SelectedPoss = workspace.ArchSettings:WaitForChild('SelectedPoss')

-- Data --
--------------------------------------- QB -----------------------------------------
local function QSlinger(JP, Speed, StaminaDrain)
	JP = 45
	Speed = 16
	StaminaDrain = 5
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'QBSLING'
end
local function QSpeed(JP, Speed, StaminaDrain)
	JP = 52
	Speed = 21
	StaminaDrain = 8
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'QBSPEED'
end
local function QARound(JP, Speed, StaminaDrain)
	JP = 50
	Speed = 17
	StaminaDrain = 6
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'QBAROUND'
end
--------------------------------------- RB -----------------------------------------
local function RSpeed(JP, Speed, StaminaDrain)
	JP = 40
	Speed = 29
	StaminaDrain = 12
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'RBSPEED'
end
local function RHop(JP, Speed, StaminaDrain)
	JP = 57
	Speed = 21
	StaminaDrain = 10
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'RBHOP'
end
local function RARound(JP, Speed, StaminaDrain)
	JP = 50
	Speed = 27
	StaminaDrain = 11
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'RBAROUND'
end
--------------------------------------- WR -----------------------------------------
local function WDomer(JP, Speed, StaminaDrain)
	JP = 58
	Speed = 20
	StaminaDrain = 5
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'WRDOME'
end
local function WSatisfactor(JP, Speed, StaminaDrain)
	JP = 55
	Speed = 25
	StaminaDrain = 8
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'WRSAT'
end
local function WSpeedster(JP, Speed, StaminaDrain)
	JP = 45
	Speed = 28
	StaminaDrain = 10
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'WRSPEED'
end
--------------------------------------- TE -----------------------------------------
local function TSpeedster(JP, Speed, StaminaDrain)
	JP = 54
	Speed = 22
	StaminaDrain = 5
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'TESPEED'
end
local function TDomer(JP, Speed, StaminaDrain)
	JP = 58
	Speed = 20
	StaminaDrain = 8
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'TEDOME'
end
local function TARound(JP, Speed, StaminaDrain)
	JP = 56
	Speed = 21
	StaminaDrain = 6
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'TEAROUND'
end
--------------------------------------- OL -----------------------------------------
local function OARound(JP, Speed, StaminaDrain)
	JP = 35
	Speed = 15
	StaminaDrain = 10
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'OAROUND'
end
local function OBIBlock(JP, Speed, StaminaDrain)
	JP = 35
	Speed = 13
	StaminaDrain = 12
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'OBLOCK'
end
local function OAthletic(JP, Speed, StaminaDrain)
	JP = 35
	Speed = 16
	StaminaDrain = 15
	local OFF = ArchFile.OFF
	OFF.Speed = Speed
	OFF.JumpHeight = JP
	OFF.Stamina = StaminaDrain
	OFF.SelectedPos = 'OATHLETIC'
end

-- Actual Code -- 
if SelectedPoss.Value == 'Home' then
	ArchFile.OFF.SelectedPos.Value = true
	ArchFile.DEF.SelectedPos.Value = false
	print('Home Possesion')
end

if SelectedPoss.Value == 'Away' then
	ArchFile.OFF.SelectedPos.Value = false
	ArchFile.DEF.SelectedPos.Value = true
	print('Away Possesion')
end

script.Parent.HB.MouseButton1Click:Connect(function()
	SelectedPoss.Value = 'Home'
end)

script.Parent.AB.MouseButton1Click:Connect(function()
	SelectedPoss.Value = 'Away'
end)
1 Like
script.Parent.HB.MouseButton1Click:Connect(function()
	SelectedPoss.Value = 'Home'
end)

script.Parent.AB.MouseButton1Click:Connect(function()
	SelectedPoss.Value = 'Away'
end)

SelectedPoss.Changed:Connect(function(newVal)
	if newVal == "Home" then
		ArchFile.OFF.SelectedPos.Value = true
		ArchFile.DEF.SelectedPos.Value = false
		print('Home Possesion')
	elseif newVal == "Away" then
		ArchFile.OFF.SelectedPos.Value = false
		ArchFile.DEF.SelectedPos.Value = true
		print('Away Possesion')
	end
end)

The reason your previous version didn’t work is because you just had those conditional statements run once to check the value (before the value was even set) so nothing would happen. I’ve made use of the “.Changed” event which is fired whenever the value of a “StringValue” instance changes, then the conditional checks are performed and the Boolean values are set accordingly.

2 Likes

Thank you. I don’t really use bool values like that so this really helped me.

1 Like