I was wondering if anyone could help me make a flag script, I am trying to make a flag on one teams side only, and I want to script it as if a enemy from the other team grabs the flag, they take it back to their base on a certain 'part' where the flag dissapears when you reach your base, and your entire team gains a point for it. Then the flag regenerates back on the other team, and you have to try repeat the process all over again. If anyone knows how to do this, please let me know, thanks!
How do I make a flag script to take flag and take it back to your base?
1 answer
First you need to figure out what mechanics you what the player to use for picking up the flag.
Touching it? [ Touched:Connect ] Key stroke? [ game:GetService("UserInputService").InputBegan:connect ] Mouse Click? [ Mouse.Button1Down:connect ]
Then how you want the player to hold the flag.
In hand? [ humanoid:EquipTool ] In backpack? [ .Parent = Player.Backpack ]
Then you use the Touched event to make a triggered plate to Destroy() the flag the player is carrying.
12 comments
game:GetService("UserInputService").InputBegan:connect ] [ Mouse.Button1Down:connect ] [ humanoid:EquipTool ] Wouldn’t work if I did try that, so how would I make all of that function in a script exactly?
So the player will have to touch the flag in order to grab the flag??
The player will have to touch the flag in order to grab it, it goes on their back (if possible) or hand.
You can place it on their back but I have never done anything like that. As for the rest you can start out by using {flagPart}.Touched:Connect() to place the flag into the players backpack by making the parent Player.Backpack.
Either one is fine. But how would I do the script? That's the hardest part here.
If you can't make the script with the suggestion I gave you sounds like you should probably start with something a bit more easier. https://www.youtube.com/watch?v=pY-s57Ap6AE this video show you how to use the touched event.
Ok. I have watched that video, understood etc. Do you have any other links to how to do this // if you could expain how to do this?
Because if I were to use touched event, I'd need to use Destroy() to destroy the flag out of the players inventory, however that would need to function points for teams aswell...
I've been looking at the ROBLOX wiki for help, destroy script etc. Just very confusing..
For destroy you find the flag and just put :destroy(). I will find an example, for you to follow if you still need one.
Yes please do. If it could give leaderboard points when it touches the part, would be a great help. Thanks
This is what I use to find and destroy an item from the players backpack Player.Backpack:FindFirstChild("Key"):Destroy() You need to define player depending where the code goes. Do you have the leaderboard created?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
THIS IS NOT A SCRIPT REQUEST SCRIPT. Instead why don't you try to make one for yourself and If you have problems regarding your script, then you can ask on this site on how to 'fix' it or 'why' is it not working...