I am making a game, and I am trying to make it so players will have a katana tool, and it will do damage to players that are on the other team.
Scripts I tryed to make for it:
local.script.function
if plr.Team = ("Ninjas")
and plr.Team("Samurai") = hit
then plr.Damage = true
then plr.Damage = -5
else
if plr.Team = ("Ninjas")
then plr.Damage = false
end
local.script.function
if plr.Team = ("Samurai")
and plr.Team("Ninjas") = hit
then plr.Damage = true
then plr.Damage = -5
else
if plr.Team = ("Samurai")
then plr.Damage = false
end
The scripts are very bad, and don’t work. Any suggestions on how I can fix it?
if plr.Team.Name = "Ninjas" and plr.Team.Name == "Samurai" then
plr.Damage = true
plr.Damage = -5
elseif plr.Team = "Ninjas" then
plr.Damage = false
end
I am very confused what you are trying to do with plr.Damage = true. I am also confused. Is it a Bool or a number? Can you clairify that please? Also if its an Attribute, use
plr:SetAttribute("Damage", -5)
And if its a basevalue, do
plr.Damage.Value = -5
local.script.function is not a thing, so I removed that. You also don’t need () for strings. Also hit doesn’t exist so I removed that. The second script should be
if plr.Team.Name = "Samurai" and plr.Team.Name == "Ninjas" then
plr.Damage = true
plr.Damage = -5
elseif plr.Team = "Samurai" then
plr.Damage = false
end
Also, the first line of code is very confusing. The team’s name cannot be 2 things.
Well, if it’s a sword you want to implement couldn’t you just do so by adding a Touched Event, then detecting whoever got hit will take damage if the Target is on the other team?
Well if you’re wanting to encase it into 1 Main Weapon System Script, you could use a Module Script to handle all of the weapon types & deal a specific amount of damage? You can use ModuleScripts to create functions that can be replicated across both the client & server, such as dealing damage to the Target
local WeaponSystem = {}
function WeaponSystem.DealDamageToTarget(Target)
--You can implement your sanity checks here to deal damage and check if the Target's Team is an Enemy or not
end
return WeaponSystem