Ad
Log in to vote
1

How to make players not kill each other?

Asked by 5 days 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 2326 — 4d

4 answers

Log in to vote
1
Answered by 5 days 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

Ad
Log in to vote
1
Answered by 5 days ago

You could use :GetPlayerFromCharacter()

Log in to vote
0
Answered by
MattVSNNL 614 Moderation Voter
5 days ago
Edited 5 days 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 2326 — 4d
0
what? MattVSNNL 614 — 4d
Log in to vote
0
Answered by 4 days 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.

Answer this question