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: Some dumb mistake I can't see

Previous Thread :: Next Thread 
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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 is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
15 Oct 2013 11:59 AM
ROLF WHAT IS THIS MESS
Report Abuse
UgOsMiLy is not online. 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
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
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
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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
BlockzieCartI is not online. BlockzieCartI
Joined: 28 Sep 2009
Total Posts: 812
16 Oct 2013 11:13 AM
Man Prestigious was harsh.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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
TheLittleEgg is not online. TheLittleEgg
Joined: 08 Feb 2012
Total Posts: 262
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
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
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 is not online. 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
BlockzieCartI is not online. BlockzieCartI
Joined: 28 Sep 2009
Total Posts: 812
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 is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
16 Oct 2013 02:27 PM
^ u wot m8
Report Abuse
airplanejoe is not online. airplanejoe
Joined: 19 Oct 2011
Total Posts: 5767
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
airplanejoe is not online. airplanejoe
Joined: 19 Oct 2011
Total Posts: 5767
16 Oct 2013 02:39 PM
From what I know i don't think there is a command called "and"
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
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
BombEater25 is not online. BombEater25
Joined: 04 Jan 2013
Total Posts: 136
16 Oct 2013 03:43 PM
You need to learn how to write scripts correctly. I can't read this.
Report Abuse
talk2me2 is not online. 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
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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 is not online. 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
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
18 Oct 2013 09:50 AM
I have done so
Report Abuse
zars15 is not online. 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
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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 is not online. 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
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
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
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