generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Anti Teamkill doesn't function as intended

Previous Thread :: Next Thread 
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 04:53 PM
I'm working on an anti teamkill script, which should prevent the Navy blue team from killing the Really Black team, but it doesn't work

function checkAlly(killer, victim)
if killer ~= victim then
if killer.TeamColor==BrickColor.new("Navy blue") and victim.TeamColor==BrickColor.new("Really black") then
return false
elseif killer.TeamColor==BrickColor.new("Really black") and victim.TeamColor==BrickColor.new("Navy blue") then
return false
elseif killer.TeamColor == victim.TeamColor then
return true
else
return false
end
return false
else
return true
end
return false
end

I can not see anything wrong. Does anyone know?
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
05 May 2014 04:54 PM
function CheckAlly(K, V) -- lazy
return K.TeamColor == V.TeamColor
end
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 05:02 PM
Okay, I built off of that, leading to this:

function checkAlly(killer, victim)
if killer ~= victim then
function CheckAlly(killer, victim)
return killer.TeamColor ("Navy blue" or "Really black") == victim.TeamColor ("Navy blue" or "Really black")
end

Am I overcomplicating things?
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
05 May 2014 05:13 PM
function CheckAlly(K, V) -- lazy
return K.TeamColor == V.TeamColor
end


Whats wrong with just this?

If they are the same team color, it returns true, if they aren't, it returns false.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 05:16 PM
Does that script look good?
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 05:17 PM
Sorry, late reply on that last one.

The teams "Navy blue" and "Really black" are for a group, and its allies. I don't want teamkilling going on between the two, so I want each to not be able to kill the other.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
05 May 2014 05:22 PM
if killer.TeamColor==BrickColor.new("Navy blue") and victim.TeamColor==BrickColor.new("Really black")



function CheckAlly(K, V) -- lazy
local KC, VC = K.TeamColor.Name, V.TeamColor.Name -- more lazy
if (KC == VC) or (KC == "Navy blue" and VC == "Really black") or (KC == "Really black" and VC == "Navy blue") then
return true
end
return false
end
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 05:51 PM
That seems like it would work.

Although the first line gives me "'then' expected near 'function'"

But it seems like it should work.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 06:01 PM
Should I be concerned?
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
05 May 2014 06:03 PM
Nevermind, conflicted with the previous script, is all.

Thank you.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 03:36 PM
Huh, after testing that script, even though it should, and looks like it would work, when placed in the main gun script, it does not function at all.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 03:38 PM
Anyone?

At this point, I have a script that SHOULD work.

But it doesn't.
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
06 May 2014 03:39 PM
Probably because when placed in a gun, It doesn't get the bullet, or the object that causes the killer to project towards the victim...
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 03:56 PM
How do you propose I should fix this issue?

I'm not the most advanced at weapon coding.
Report Abuse
NiceCoder is not online. NiceCoder
Joined: 15 Oct 2012
Total Posts: 6593
06 May 2014 03:57 PM
this isnt even your script lol
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 03:58 PM
Good eye.

I'm not a great gun coder, as I've said previously.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 04:00 PM
And some help on where to put this section of code would be appreciated.
Report Abuse
NiceCoder is not online. NiceCoder
Joined: 15 Oct 2012
Total Posts: 6593
06 May 2014 04:00 PM
from my c&g experience the rcl gun script should do you and then if you know any decent lua you should be able to modify the anti-tk into several teams
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 04:02 PM
That sounds like it could work.

Although I all ready have the script mentioned earlier (not the first one) that would work just fine.

I just need formatting help.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 04:06 PM
No?

The RCL script can be used as a backup if I can not find help on my current script.
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 04:10 PM
I could use a bit of help.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
06 May 2014 04:22 PM
You have to check if they are on the team before doing damage

the function is so you can do

if CheckAlly(PlayerAttacking, PlayerTheyHit) then
-- do damage
end
Report Abuse
Hockey868 is not online. Hockey868
Joined: 08 May 2011
Total Posts: 12805
06 May 2014 04:42 PM
local allycolours = {BrickColor.new("Navy blue"), BrickColor.new("Really black")}
local plrAlly = false
local eplrAlly = false
for i = 1, #allycolours do
if plr.TeamColor == allycolours[i] then
plrAlly = true
end
if eplr.TeamColor == allycolours[i] then
eplrAlly = true
end
end
-- check if players can kill eachother
if eplr.TeamColor ~= plr.TeamColor and (eplr.TeamColor ~= sp.Values.Nonhittable.Value) or eplr.Neutral or plr.Neutral then
-- check if players are allies
if plrAlly == true and eplrAlly == true then
if CheckAlly(PlayerAttacking, PlayerTheyHit) then
end
else
tagHumanoid(humanoid)
humanoid:TakeDamage(damage)
game.Players.LocalPlayer.PlayerGui.HIT:play()
game.Players.LocalPlayer:findFirstChild("PlayerGui").MouseGUI.Hit.Visible = true
end
end

This is it so far.

Anything I missed?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image