Capture The Flag design

Hello,

So I am working on a capture the flag game mode for my paint ball game and I’m trying to figure out the best/most efficient way to prevent a player from using weapons while holding the flag without having to destroy the tools in the players back pack.

Currently, the capture the flag script welds the flag model to the players hand when the flag is touched. The flag also has a boolean value called “beingHeld” and an object value called “owner” that refers to the character object of the player that the flag is welded to.

1 Like

You can do something like this to clone the tools and return it to the player afterwards:

if beingHeld == true then
    storedBackpack = plr.Backpack:GetChildren()
    plr.Backpack:ClearAllChildren()
    repeat
        wait()
    until beingHeld == false
    for i,v in pairs(storedBackpack) do
        v:Clone().Parent = plr.Backpack
    end
end

Then try making so that if player equips any weapon while holding the flag, making .Parent back to the .Backpack from the character.

Thank you,this is a good solution.

No problem, and also forgot to add yes what @Andr_yy said. Add this to check if there are tools in hand:

for i,v in pairs(plr.Character:GetChildren()) do
    if v:IsA("Tool") then
        table.insert() --Insert it into whichever table you would like to store them in.