How to turn PVP on and off?

Hey, so am making a game where you could fight people in an arena, however, I want to make it so that you cannot PVP in the lobby but when in the arena you can.
How would I go about doing this?
I was thinking of adding a part that has collision turned off and while its touched there would be a script allowing PVP, however, I do not know how to do this.
What’s the best way for doing this?

2 Likes

You could give them a forcefield when they turn it off and when they turn it on you remove their forcefield

1 Like

You’re going to want to either have a central script on the server that manages damage requests from tools, or update tools to check a state before they do humanoid:TakeDamage()

You could put a BoolValue object in replicated storage, and have that act as “PvP_Mode” and have the tools check if the PvP_Mode.Value is true before applying damage to targets.

3 Likes

Hey,so I would like need to know how the tools work? Because I am currently using a free tool,I was thinking of making my own though since the free tool comes with a lot of problems

I was thinking of that but it would be ugly for players to see a force field around them at all times.

Items from the toolbox can be a good starting point if you are new. Making an entirely new tool can be a little daunting at first. I’d suggest continuing to use tools from the toolbox that work, and modifying them, atleast until you feel more comfortable writing them from scratch yourself.

You can use Ctrl+Shift+F to search all scripts in your game. Do this to search for “TakeDamage” or “.Health”

Everywhere you find code that seems to be dealing damage, you can add a condition around with, like…

if game.ReplicatedStorage.PvP_Mode.Value == true then
	-- Damage code here
end

Just insert a BoolValue into ReplicatedStorage, and name it “PvP_Mode”

You can then change the mode from any script with…

game.ReplicatedStorage.PvP_Mode.Value = true
4 Likes

Thanks, I’ll try that :smile: (30CHAR)

1 Like

Thanks a lot! I just found the damage code and now can easily disable it :smile:

1 Like