Summary: When a player is holding a flag, they have selection boxes put into every one of their body parts. If they capture the flag, the selection boxes should be removed
Script to do action:
local nameh = ""--Stores flag holder's name
function touchEnter()
if script.Parent.Parent.Name ~= "BlueFlag" then
nameh = script.Parent.Parent.Name
workspace.CapturesChecker.BlueFlagHolder.Value = nameh--Gets flag holder's name
workspace.CapturesChecker.Main.Disabled = false--Disables a script
end
end
function onPropChange(obj, parent)
if parent.Name == "BlueFlag" or parent == workspace then--If the flag is back at its stand or in workspace, then
workspace.CapturesChecker.BlueFlagHolder.Value = "None"--Ignore this stuff
workspace.CapturesChecker.Main.Disabled = false
local c = game.Players[nameh].Character--This is where the problem starts
c.Head.SelectionBox:Destroy()--These are lines to destroy the selection boxes, however they still exist
c.Torso.SelectionBox:Destroy()
c["Left Arm"].SelectionBox:Destroy()
c["Right Arm"].SelectionBox:Destroy()
c["Left Leg"].SelectionBox:Destroy()
c["Right Arm"].SelectionBox:Destroy()
end
end
script.Parent.Equipped:connect(touchEnter)
script.Parent.AncestryChanged:connect(onPropChange)
Problem: The selection boxes aren't destroyed. The event is fired (GUIs change after the event is fired) but the selection boxes still exist within the player's body parts. What am I doing wrong and how can it be fixed?

1 comment
Sorry, the console throws an error when I try this. The script now probably thinks that SelectionBox is a property.