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 » Scripters
Home Search
 

Re: What is wrong with my script??

Previous Thread :: Next Thread 
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
19 Jun 2015 02:58 PM
So I have had some help with this script but I still don't understand what is wrong with it?? Can someone please tell me?


function NG()
game.Workspace.Lobby.NGP.Parent = game.ServerStorage
end

function Death()
player.Character.Humanoid.Died = Team.BrickColor.new("Neon orange")
end



while wait(3) do


msg = game.Workspace.Hint

msg.Text = "Choose Your NightGuard"
wait(6)
if game.Workspace.Lobby.NGP.touched:connect(NG)then
end

msg.Text = "Pick your role"
wait(6)

msg.Text = "Starting game in..."
wait(1)
msg.Text = "5"
wait(1)
msg.Text = "4"
wait(1)
msg.Text = "3"
wait(1)
msg.Text = "2"
wait(1)
msg.Text = "1"
wait(.6)
msg.Text = "Starting Game NOW"

wait(200)
if Team.BrickColor("Toothpaste").players.Humanoid.Died then
msg.Text = "NightGuard has been killed"
or
Team.NightGuard.players.Humanoid.Health == 100
game.Workspace.Player:findFirstChild("Humanoid")
Humanoid.Health = 0

Death()

wait(5)
msg.Text = "Restarting..."

wait(2)
end

The problem is that the game does not show the messages and does not add player to team toothpaste aka NightGuard...

Someone please help!!
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Jun 2015 03:02 PM
"player.Character.Humanoid.Died = Team.BrickColor.new("Neon orange")"

LOL LMFAO
Report Abuse
Superdarkninja44 is not online. Superdarkninja44
Joined: 07 Oct 2012
Total Posts: 2176
19 Jun 2015 03:06 PM
I'm sorry but there is loads wrong with that.
Report Abuse
DeathsLASTwords is not online. DeathsLASTwords
Joined: 28 Jan 2012
Total Posts: 2701
19 Jun 2015 03:09 PM
player.Character.Humanoid.Died

wew lad, youve got a lot to learn.
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
19 Jun 2015 03:11 PM
hey can you all not be jerks I just am learning to script so instead of saying Wow lol wtf does he mean can you tell me what im doing wrong >:(
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
19 Jun 2015 03:12 PM
Oh and the whole Humanoid.Died I know how to fix that Humanoid.health = 0 then Team.BrickColor.new("Neon Orange") right?
Report Abuse
Superdarkninja44 is not online. Superdarkninja44
Joined: 07 Oct 2012
Total Posts: 2176
19 Jun 2015 03:13 PM
@DENZALLL
I would advise that you read through the roblox wiki and learn how to script better because there are so much stuff wrong with that script that a lot of people don't want to fix all the errors. You still need to learn a lot.
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
19 Jun 2015 03:15 PM
Yeah I am using the wiki and that is where I am mostly learning from but this I can fix I just am going to see what I can do
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
19 Jun 2015 03:15 PM
But will my script still not work if I put the functions above "while wait(3) do"???
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
19 Jun 2015 03:18 PM
And also if anyone can at least tell me 1 thing they see that is wrong please do it would help a lot
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
19 Jun 2015 03:33 PM
Okay, I'll go through some of it:

function NG()
game.Workspace.Lobby.NGP.Parent = game.ServerStorage
end -- This function should work. It will have the effect of moving the model NGP in Lobby out of the game world and into storage.


function Death()
player.Character.Humanoid.Died = Team.BrickColor.new("Neon orange")
end

-- This function will not work. I can infer what you wanted to do (Moving a player who died to another team), but the computer cannot.
How you would actually accomplish this is you would connect a function to a Humanoid's Died event (informing the computer that you wish for it to call the function when the event fires.

Such a command would look something like this:
Character.Humanoid.Died:connect(Death)

But that poses its own problem: What is "Character?" How can the computer know what a Character is, much less which one you want to use here? One simple way would be to instruct it to connect the Death function to each Character as they spawn. To do so, we would have to connect a function with the aforementioned connection line to a Player's CharacterAdded event (http://wiki.roblox.com/index.php?title=CharacterAdded).

So we now have

Player.CharacterAdded:connect(function(Character)
Character.Humanoid.Died:connect(Death)
end)

(If this connection line looks strange to you, don't worry about it! This is called an anonymous function - a function without a name. Since this function (which I would name OnCharacterAdded if I had to) is never used again, there's no reason to store it in a variable. Rather, we define it inside the call to :connect() and Lua concludes that we must mean to pass it to connect.

But this poses one last problem: What is 'Player'? The computer needs to know where to look for the CharacterAdded event. One simple way is to tell it to connect this function to every Player that spawns. This would look like this:

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character.Humanoid.Died:connect(Death)
end)
end)

This block of code, translated to English, instructs the computer to do the following:

Access the CharacterAdded event in game.Players. Whenever it fires do the following:
Access the CharacterAdded event in the newly added Player. Whenever it fires, do the following:
Access the Died event in the new Character's Humanoid child. Whenever it fires, do the following:
Call the function called Death.

There's one last problem, though: when the function Death is called, it receives no information! This is because the .Died event passes the function no information (which you can see from this page: http://wiki.roblox.com/index.php?title=Died)

To solve this, we have a few options. The easiest though, is to take advantage of a quirk in how Lua works: Functions defined in other functions have access to the outer function's local variables. So if, rather than defining Death like this:

function Death()
...
end

We define it inside, like the other anonymous functions,

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
Character.Humanoid.Died:connect(function()
Player.TeamColor = BrickColor.new("Neon orange")
end)
end)
end)


PS: Don't feel discouraged! When I posted my first game's main script (for the same reason, to ask what was wrong), I got about the same response!
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
20 Jun 2015 11:36 AM
Ok thanks
Report Abuse
DENZALLL is not online. DENZALLL
Joined: 08 Dec 2013
Total Posts: 66
22 Jun 2015 02:52 PM
There is still problems like the messages wont show up and when the player touches the NGP brick(is a spawnlocation) and reset they spawn back on NGP and do not change teams
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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