Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make players not kill each other?

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.

1 comment

0

please show your sword script!!!

4 answers

✓ Accepted answer

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.

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

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)

2 comments

0

i mean if they can kill the npc the npc might be able to kill the players aswell

0

what?

This discussion is preserved as it was. New answers, comments, and votes are closed.