I really don't know how I can disable PVP on my game. I really don't want any PVP at all. That means that explosions caused by players cannot hurt other players. I've tried searching everywhere on the internet but I really cannot find anything.
Is it possible that I could put something like this in my 'sword' weapon?
local sword = game.Workspace:FindFirstChild("Sword") if sword then local humanoid = game.Workspace:FindFirstChild("Humanoid") humanoid.Touched:connect(function(disable) --I don't know what I have to do!-- end) end
I'm really not sure whether this whole script is even correct. I'm new to scripting so please, please understand me. Please check if that script is correct and please tell me what I have to add to the script.
Sword would be inside the player in workspace (or the backpack in the player), not workspace itself and that goes for the humanoid also. You wouldn't need disable as a parameter unless you are doing something odd. Idk what you mean by explosions being as they aren't included in the script. If the script is inside of the sword, then you could just do sword = script.Parent. You have to know what you are trying to disable in order to disable a certain part of the weapon, like I don't know what type of sword you are using otherwise I would just find the script in the sword for dealing damage and destroy it or disable it and if you just wanted it to damage certain things then I would make my own damaging script inside the sword.
If you are wanting to give all players a power to where they can't die, try this.
local Sword = game.Workspace:FindFirstChild("Sword") local TouchForPvp = Instance.new("Part", game.Workspace) -- or if you have a part in workspace, put this script in the part and do local TouchForPvp = script.Parent if game and game.Workspace and Swordthen TouchForAntiPvp.Touched:connect(function(Player) if Player and Player.Parent.Humanoid then Player.Parent.Humanoid.MaxHealth=math.huge else warn("Game or Sword are broke, or is not found..") end end) end -- Pvp function if game and game.Workspace and Sword then TouchForAntiPvp.Touched:connect(function(Player) if Player and Player.Parent.Humanoid then Player.Parent.Humanoid.MaxHealth=100 else warn("Game or Sword are broke, or is not found..") end end) end
Hope I helped!