|
| 15 Oct 2013 11:13 AM |
The title explains it all, I can't post the whole script but hopefully the section I can post will be enough. It's pretty self-explanatory, it's a gun script that checks what team the target is on before doing damage, you'll notice Survivors, Gun Dealers and Medics are allied against Bandits. ANy help is greatly appreciated (:
if humanoid.Health>0 then local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(sp.Parent) if eplr~=nil and plr~=nil then if plr.Team == "Survivors" then if eplr. TeamColor ~= "Gun Dealers" and if eplr. TeamColor ~= "Medics" and if eplr. TeamColor ~= "Survivors" or if plr.Team == "Gun Dealers" then if eplr. TeamColor ~= "Survivors" and if eplr. TeamColor ~= "Medics" and if eplr. TeamColor ~= "Gun Dealers" or if plr.Team == "Medics" then if eplr. TeamColor ~= "Gun Dealers" and if eplr. TeamColor ~= "Survivors" and if eplr. TeamColor ~= "Medics" or if plr.Team == "Bandits" then if eplr. TeamColor ~= "Bandits" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) end else tagHumanoid(humanoid) humanoid:TakeDamage(damage) end end end |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
| |
|
UgOsMiLy
|
  |
| Joined: 15 Sep 2009 |
| Total Posts: 2095 |
|
|
| 15 Oct 2013 01:00 PM |
| The script might not understand what humanoid you are talking about. |
|
|
| Report Abuse |
|
|
|
| 15 Oct 2013 01:02 PM |
if team color equals string value, are you stupid?
if Player.TeamColor == BrickColor.new("Really black") -- or whatever colour it be.
|
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 10:57 AM |
| Wow, I knew it was some dumb mistake, it was early in the morning when I was writing this xD |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 11:13 AM |
| Man Prestigious was harsh. |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 11:22 AM |
| After remedying the whole 'TeamColor' mess it's still not working, is there something else I'm doing wrong? :T |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 11:27 AM |
"local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(sp.Parent)"
shouldn't it be :GetPlayerFromCharacter()? |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 11:36 AM |
No, I think that's ok. It's giving me an error on line seven for some reason :T |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 01:10 PM |
"TeamColor" and you are asserting a NAME. You want a COLOR.
Instead of putting the name of the team, put the color of the team.
if player.TeamColor == BrickColor.new("Bright red") then -- Replace whatever Bright red with whatever
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 16 Oct 2013 01:11 PM |
| dude learn to Lua before doing this stuff because this is horrid bro |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 02:20 PM |
local player = universe.Players:GetPlayers(universe) if player then if player.Name == "blocco" then player.Character:MoveTo(universe.Galaxies.Milkyway.Sol.AsteroidBelt.Asteroid292.Position) print 'owned' end end |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
| |
|
|
| 16 Oct 2013 02:38 PM |
um
why is there so many if?
You need if then, else
your script has 1% logic |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 02:39 PM |
| From what I know i don't think there is a command called "and" |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 03:16 PM |
if eplr. TeamColor ~= "Gun Dealers" and eplr. TeamColor ~= "Medics" then -- etc [whatever] end
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 03:43 PM |
| You need to learn how to write scripts correctly. I can't read this. |
|
|
| Report Abuse |
|
|
talk2me2
|
  |
| Joined: 25 Mar 2011 |
| Total Posts: 1051 |
|
|
| 16 Oct 2013 04:02 PM |
local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(sp.Parent)
It is :GetPlayerFromCharacter. (I think.)
-Talk,
|
|
|
| Report Abuse |
|
|
|
| 18 Oct 2013 09:45 AM |
It's been a year since I've even looked at Lua (Not that I was ever anything more than a beginner anyways) so you'll have to excuse the terrible attempt. Even after adjusting to all the feedback I got here the script still doesn't work, can someone tell me precisely where I'm going wrong here? I want to learn :3 |
|
|
| Report Abuse |
|
|
Aerr0w
|
  |
| Joined: 09 Apr 2009 |
| Total Posts: 565 |
|
|
| 18 Oct 2013 09:48 AM |
| I am not sure, but you should use "elseif" for multiple "if's". |
|
|
| Report Abuse |
|
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 18 Oct 2013 10:02 AM |
Ah,
if a==b and if c==d
That obviously will cause problems. Have it either like this:
if a==b and c==d then --stuff end
or
if a==b then --stuff elseif c==d then --stuff end |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2013 10:36 AM |
Thank you zars, that is very helpful. I THINK I've fixed up that mess but I'm now getting an error further down the script, on the last 'else', can anyone tell me why?
if humanoid.Health>0 then local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(sp.Parent) if eplr~=nil and plr~=nil then if plr.Team.Name == "Survivors" and eplr.Team.Name ~= "Gun Dealers" or eplr.Team.Name ~= "Medics" or eplr.Team.Name ~= "Survivors" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) end elseif plr.Team.Name == "Gun Dealers" and eplr.Team.Name ~= "Gun Dealers" or eplr.Team.Name ~= "Medics" or eplr.Team.Name ~= "Survivors" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) end elseif plr.Team.Name == "Medics" and eplr.Team.Name ~= "Gun Dealers" or eplr.Team.Name ~= "Medics" or eplr.Team.Name ~= "Survivors" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) end elseif plr.Team.Name == "Bandits" and eplr.Team.Name ~= "Bandits" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) end else tagHumanoid(humanoid) humanoid:TakeDamage(damage) end end if (hit.Parent:findFirstChild("Hit")) then hit.Parent.Health.Value = hit.Parent.Health.Value - BaseDamage/3 end distance=(startpoint-pos).magnitude distance2 = (startpoint2-pos).magnitude bullet.CFrame=cfrm*CFrame.new(0,0,-distance/2) bullet.Mesh.Scale=Vector3.new(.15,.15,distance) print(bullet.Parent,"shot") if doublemode == 2 and double then bullet2.CFrame = cfrm2*CFrame.new(0,0,-distance2/2) bullet2.Mesh.Scale = Vector3.new(.15,.15,distance2) print(bullet.CFrame.p,bullet2.CFrame.p) end else bullet.CFrame=cfrm*CFrame.new(0,0,-RayLength/2) bullet.Mesh.Scale=Vector3.new(.15,.15,RayLength) if doublemode == 2 and double then bullet2.CFrame = cfrm2*CFrame.new(0,0,-RayLength/2) bullet2.Mesh.Scale = Vector3.new(.15,.15,RayLength) end end
|
|
|
| Report Abuse |
|
|
spikey490
|
  |
| Joined: 06 Oct 2008 |
| Total Posts: 229 |
|
|
| 18 Oct 2013 10:53 AM |
You didn't want the ends before the elseifs.
if humanoid.Health>0 then local eplr=game.Players:playerFromCharacter(humanoid.Parent) local plr=game.Players:playerFromCharacter(sp.Parent) if eplr~=nil and plr~=nil then if plr.Team.Name == "Survivors" and eplr.Team.Name ~= "Gun Dealers" or eplr.Team.Name ~= "Medics" or eplr.Team.Name ~= "Survivors" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) elseif plr.Team.Name == "Gun Dealers" and eplr.Team.Name ~= "Gun Dealers" or eplr.Team.Name ~= "Medics" or eplr.Team.Name ~= "Survivors" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) elseif plr.Team.Name == "Medics" and eplr.Team.Name ~= "Gun Dealers" or eplr.Team.Name ~= "Medics" or eplr.Team.Name ~= "Survivors" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) elseif plr.Team.Name == "Bandits" and eplr.Team.Name ~= "Bandits" then tagHumanoid(humanoid) humanoid:TakeDamage(damage) else tagHumanoid(humanoid) humanoid:TakeDamage(damage) end end if (hit.Parent:findFirstChild("Hit")) then hit.Parent.Health.Value = hit.Parent.Health.Value - BaseDamage/3 end distance=(startpoint-pos).magnitude distance2 = (startpoint2-pos).magnitude bullet.CFrame=cfrm*CFrame.new(0,0,-distance/2) bullet.Mesh.Scale=Vector3.new(.15,.15,distance) print(bullet.Parent,"shot") if doublemode == 2 and double then bullet2.CFrame = cfrm2*CFrame.new(0,0,-distance2/2) bullet2.Mesh.Scale = Vector3.new(.15,.15,distance2) print(bullet.CFrame.p,bullet2.CFrame.p) end else bullet.CFrame=cfrm*CFrame.new(0,0,-RayLength/2) bullet.Mesh.Scale=Vector3.new(.15,.15,RayLength) if doublemode == 2 and double then bullet2.CFrame = cfrm2*CFrame.new(0,0,-RayLength/2) bullet2.Mesh.Scale = Vector3.new(.15,.15,RayLength) end end |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2013 11:36 AM |
Thank you very much, Spikey. One last thing, how come this doesn't effect NPCs? (i.e. the gun won't do damage to them) |
|
|
| Report Abuse |
|
|