Alright, so the script goal is that it will detect if the plr is a plr, and if it is a plr it’ll check if the player is allied or not. If they are, the script ends there and if they aren’t then the script will else onto if the character has the same name as them, and if they finally don’t then the character will take damage with a part surrounding the NPC
I’ve tried remaking the script many times but It’ll always have one of three problems, 1: The enemies damage each other, but not players. 2: The enemies damage players, but not enemies. 3: (which this script is on) Neither will take damage.
How can I make it to where the script will damage unallied players or NPCS with different names as them? (and allied no damage, of course)
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit)
if plr ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Allied = player.factions.Allied.Value
if Allied == true then
wait()
print("allied")
else
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= script.Parent then
if hit.Parent.Name == script.Parent.Parent.Name then
wait()
else
print("take dmg")
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(script.Damage.Value)
end
end
end
end
end)
I’m really bad at scripting.