I am trying to make a capture the flag system. What’s supposed to happen is when you touch a green circle, the display flag disappears and a smaller flag I have in replicated storage is supposed to duplicate and attach onto the Humanoid Root Part (The Back of the player). The smaller flag is a model. The first part of the script works well, it goes through with no error, but when I run back on the circle, I get the error:
Workspace.BlueBase.CapturePart.Script:12: attempt to index boolean with ‘Value’
The, “BLUE_CAPTURED_VALUE” is a global boolean variable.
Script:
local BLUE_CAPTURED_VALUE = game.ReplicatedFirst.BlueCaptured
local TOUCH_PART = script.Parent
local FLAG = script.Parent.Parent.BlueFlag
local Players = game:GetService("Players")
local debounce = false
TOUCH_PART.Touched:Connect(function(hit)
if not debounce then
debounce = true
if hit then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player and player.TeamColor == BrickColor.new("Bright red") and BLUE_CAPTURED_VALUE.Value == false then
FLAG.Union.CanCollide = false
FLAG.Part.CanCollide = false
FLAG.Union.Transparency = 1
FLAG.Part.Transparency = 1
FLAG.Part.ParticleEmitter.Enabled = false
print("1")
local TORSO = player:FindFirstChild("Humanoid")
local CAPTURED_FLAG = game.ReplicatedStorage.PlayerFlags.BlueTeamFlag:Clone()
CAPTURED_FLAG.Parent = player
print("2")
local WELD = Instance.new("Weld", TORSO)
WELD.C0 = CFrame.new(0,0,2)
WELD.C1 = CFrame.new(0,0,2)
WELD.Part0 = CAPTURED_FLAG.PrimaryPart
WELD.Part1 = TORSO
print("3")
BLUE_CAPTURED_VALUE = true
end
end
wait(0.5)
debounce = false
end
end)
Any idea why I’m getting this error and why the smaller flag is not appearing on the player’s back?