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

Pvp System doesn't work as intended?

Asked by 5 years ago
Edited 5 years ago

The player should be able to damage the other player only IF pvp is true, however the player can damage the player regardless if the pvp is false. (I checked on local server, the pvp value also changes on server, yet it still damages)

if pvp script:(Server)

if game.Players[enemyCharacter.Name] ~= nil then -- Enemy player
    local enemyPlayer = game.Players[enemyCharacter.Name]
    if enemyPlayer.Pvp.Value == true then -- if Pvp.Value is true then proceed with damage, if not then dont damage
        local hum = vCharacter:findFirstChild("Humanoid") -- Attacking player's humanoid
        if humanoid~=nil and humanoid ~= hum and hum ~= nil then
            print("SWORD HIT PLAYER")
            tagHumanoid(humanoid, vPlayer)
            getPlayerDamage(humanoid, vPlayer, enemyPlayer)
            wait(1)
            untagHumanoid(humanoid)
        end
    else
    print("Not on PVP")
    end
end

Toggle pvp script:(Server)

game.ReplicatedStorage.RemoteEvents.PVPToggle.OnServerEvent:Connect(function(player)
    if player.Pvp.Value == true then
        player.Pvp.Value = false
    else
        player.Pvp.Value = true
    end
end)

Answer this question