Hello Scripters!
Recently I Had Been Working On A Slap Battles Fan Game.
And Had Been Making All The Features By Myself And One Other Person.
And I Want To Skip A Line If The Parent Isn’t A Player.
if game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui:WaitForChild("no touchey").TextButton.BackgroundColor3 == Color3.fromRGB(0, 255, 0) then
Because Theres Alot Of NPC’s Attacking you In This Game. I dont know why?
Thanks For Whoever Clicked On This
Could you elaborate on what you mean by
“Skip A Line If The Parent Isn’t A Player.”
2 Likes
I Meant By If The Player Dosent Exist And Its Just An NPC
2 Likes
if <condition> then
-- line that will be skipped if condition is not true.
-- code inside this block will run if condition IS true
end
print("what the sigma") -- this line will happen either way
4 Likes
You can probably add a BoolValue named “IsNPC” to any NPC that spawns and check for that.
if game.Players:GetPlayerFromCharacter(hit.Parent).Character.IsNPC == true then
-- some code here
end
(I am not an experienced scripter. I don’t know if this code is wrong or right)
1 Like
i tried that befor but it only made it less optomized and made the code 144 lines long
1 Like
What kind of code are you writing? Most of my scripts are around 10-20 lines only
1 Like
i tried it and it looks promising. the only thing we need to do is to try it with the button being on
yo bro it actually worked. thanks alot
oh it was just like a punch script
Correct me if I’m wrong but a punch script is usually 10-30 lines