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.
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)