Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I disable all PVP on my game?

Asked by 7 years ago
Edited 7 years ago

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.

0
Add a check to see if what the sword hit is a player or not. User#11440 120 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

0
So, I would just place a script in the sword, and in the script, the variable 'sword' will be 'script.Parent'. And I would just let it have its normal functions when you left click it. But I would have to change the script to make it only attack certain humanoids. But how do I define that certain type of humanoid? And what do I do to like 'cancel' any damage when a player is hit by the sword? Inscendio 42 — 7y
0
Find the script in the sword that does damage and disable that script or that part of the script and the sword won't do any damage. Then you can make your own script or just remake that part of the script to where it checks for hit.Parent to be certain things. RockerCaleb1234 282 — 7y
Ad
Log in to vote
1
Answered by 7 years ago

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!

Answer this question