How could I make a player that has a Flag on them glow? [CTF Game]

I’m working on a CTF (Capture The Flag) game and would like to make a script to give a player a highlight effect if they have picked up a flag

Here’s an image example on what I’m trying to achieve :

Here’s a link to my game if you’d like to see how the game works :

How could I achieve this? Any help is appreciated!

Just insert a Highlight affect in a script use instance.new

But how would I know if a player has the flag or not?

i need to see the script where you detect when the player has captured the flag

I think this is what you want :

local function PickupFlag(player, flagObject)
	FlagCarriers[player] = flagObject
	flagObject.AtSpawn = false
	flagObject.PickedUp = true
	
	local torso
	if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
		torso = player.Character:FindFirstChild('Torso')
	else
		torso = player.Character:FindFirstChild('UpperTorso')
	end
	local flagPole = flagObject.FlagPole
	local flagBanner = flagObject.FlagBanner
	
	flagPole.Anchored = false
	flagBanner.Anchored = false
	flagPole.CanCollide = false
	flagBanner.CanCollide = false
	local weld = Instance.new('Weld', flagPole)
	weld.Name = 'PlayerFlagWeld'
	weld.Part0 = flagPole
	weld.Part1 = torso
	weld.C0 = CFrame.new(0,0,-1)
end

Ok,

local function PickupFlag(player, flagObject)
	FlagCarriers[player] = flagObject
	flagObject.AtSpawn = false
	flagObject.PickedUp = true

	local torso
	if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
		torso = player.Character:FindFirstChild('Torso')
	else
		torso = player.Character:FindFirstChild('UpperTorso')
	end
	local flagPole = flagObject.FlagPole
	local flagBanner = flagObject.FlagBanner

	flagPole.Anchored = false
	flagBanner.Anchored = false
	flagPole.CanCollide = false
	flagBanner.CanCollide = false
	local weld = Instance.new('Weld', flagPole)
	weld.Name = 'PlayerFlagWeld'
	weld.Part0 = flagPole
	weld.Part1 = torso
	weld.C0 = CFrame.new(0,0,-1)

	local hightlight = Instance.new("Highlight", player.Character)
	
	
	hightlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
	
	hightlight.FillColor = player.TeamColor
	hightlight.OutlineColor = player.TeamColor


end

and if the player putted the flag down or has finished capture the flag then just remove the highlighter, I might need to see where the part the player has no longer hold the flag

I think you need this :

local function DestroyFlag(flagObject)
	flagObject.Flag:Destroy()
	for player, object in pairs(FlagCarriers) do
		if object == flagObject then
			FlagCarriers[player] = nil
		end
	end
end

I might need more script related to that DestroyFlag Functions

I managed to figure out on how to destroy the highlight myself this second, thank you for helping me out!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.