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

How to make players not kill each other?

Asked by 2 years ago

I'm making a game in and I'm new to Roblox I'm having trouble finding any videos on how to do this as my players are supplied with swords in there backpack but one issue is that i want players to only be able to kill Npcs. If you can please help.

0
please show your sword script!!! Xapelize 2658 — 2y

4 answers

Log in to vote
0
Answered by 2 years ago

I'm going to assume you are using the default Roblox Sword from the toolbox. Well since you are a novice and you are looking for a simple solution I'll tell you. You can create a team and set that team to neutral. This way since everyone will be on the same team, they will not be able to kill another player. This might be a messy workaround, but this will work.

Ad
Log in to vote
1
Answered by 2 years ago

You can add value inside player name it "isPlayer" and modify sword script so that whenever they attack something, you should make it so that if there is "isPlayer" inside of them you should not damage

Log in to vote
1
Answered by 2 years ago

You could use :GetPlayerFromCharacter()

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago
Edited 2 years ago

Hello,

I made a script that detects when a player joins, then it sets their health to INF so they can't die!

Script in ServerScriptService (not a localscript and not a modulescript)

local PlayersService = game:GetService("Players")

PlayersService.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)

        local humanoid = char:FindFirstChild("Humanoid")

        if humanoid then

            humanoid.Health = math.huge

        end

    end)
end)
0
i mean if they can kill the npc the npc might be able to kill the players aswell Xapelize 2658 — 2y
0
what? MattVSNNL 620 — 2y

Answer this question