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: What is wrong with this script?

Previous Thread :: Next Thread 
starwarsfirstfan is not online. starwarsfirstfan
Joined: 24 Apr 2010
Total Posts: 385
19 Nov 2011 10:04 AM
Game.Workspace.starwarsfirstfan.health = 0
Starwarsfirstfan = Kill When Commanded
Commnd 'star'
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
19 Nov 2011 10:05 AM
trololooloololoolol

my eyes hurt
Report Abuse
starwarsfirstfan is not online. starwarsfirstfan
Joined: 24 Apr 2010
Total Posts: 385
19 Nov 2011 10:05 AM
I suck at scripting i just started today and i wanted to try it my self
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
19 Nov 2011 10:06 AM
OH, i thought you were just trolling.

Hold on
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
19 Nov 2011 10:08 AM
game.Workspace.Starwarsfirstfan.Humanoid.Health = 0
function onChatted(msg)
if msg == "star" then
game.Workspace.Starwarsfirstfan.Humanoid.Health = 0
end
end
game.Players.Starwarsfirstfan.Chatted:connect(onChatted)

-- Explanation on next reply--
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
19 Nov 2011 10:09 AM
Game.Workspace.starwarsfirstfan.health = 0
Starwarsfirstfan = Kill When Commanded
Commnd 'star'


Well, let's see...

Your 'Health' is located in your 'Humanoid'.
Workspace.starwarsfirstfan.Humanoid.Health


The last two lines don't resemble any sort of RBX.Lua that I've seen.

You should use a .PlayerAdded-called function, with an 'if' statement that calls a function that iterates through a table of administrator names, and compare it to the name of the added player. If that is true, then call a new function with the .Chatted event.

From there, you want to check to see if a certain substring of what was chatted is a 'command' of yours. Then, you will use the rest, and find the text in a name in the list of Players.
Do as you wish, and you then can add more using 'elseif''s, when checking for certain substrings.
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
19 Nov 2011 10:16 AM
ServerLabs' script would work on a script builder, for example.

If you wanted it to work, elsewhere, that kind of connection line would break the script, as it runs before 'game.Players.starwarsfirstfan' exists.


local admin = "starwarsfirstfan"
game.Players.PlayerAdded:connect(function(np)
if np.Name == admin then
np.Chatted:connect(function(msg)
if msg:lower():find("star") then
if game.Players[admin].Character then
game.Players[admin].Character:BreakJoints()
end
end
end)
end
end)

This is a simpler version, made to do what you asked. If anywhere in your message, you say 'star', you will die. Now, if you want to make sure the entire message is 'star', before you die, you can use..

local admin = "starwarsfirstfan"
game.Players.PlayerAdded:connect(function(np)
if np.Name == admin then
np.Chatted:connect(function(msg)
if msg:lower() == "star" then
if game.Players[admin].Character then
game.Players[admin].Character:BreakJoints()
end
end
end)
end
end)
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
19 Nov 2011 10:23 AM
-- Breakdown of the first line.

"Health" is a property of "Humanoid", a child of "Starwarsfirstfan", a child of "Workspace", which is a child of "game".

"Health" -> Number
"Humanoid" -> UserData [Object]
"Starwarsfirstfan" -> UserData [Object]
"Workspace" -> UserData [Object]
"game" -> UserData [Object]

If MaxHealth is "x" then the greatest amount of health you can have is "x". Health has a minimum of 0 [Death] and "x" [Fully healed]

-- Breakdown of second line.

"function" is a global-use statement, the numbers and letters (grouped together with no spaces or symbols) after that statement are made into a function, opening up a block, or "chunk" as some people call it.

In this case, we used "onChatted", and made the arguments (specified in between the parenthesis) "msg", more than one variable can be added as long as they are separated with commas.

-- Breakdown of third line.

"if" is also a statement, and it's syntax is:

if x == y then

if, followed by a value, followed by a comparison, followed by another value, followed by "then", opening up another chunk.

-- Breakdown of fourth line.

If the "if" statement returns true, it will continue to the next line, if false it will skip over.

Again, we will be using game.Workspace.Starwarsfirstfan.Humanoid.Health = 0.

If you say "star", without quotes, you will be killed (by your health dropping to 0.)

-- Fifth line closes "if" chunk

-- Sixth line closes "function" chunk

-- Breakdown of seventh line

:connect() is a method of .Chatted, an event of Starwarsfirstfan triggered when you chat; a child of Players, and a child of game.

When the event is triggered, the function specified in between the parenthesis of :connect() will be called, and the argument the event returns will be passed onto the FIRST argument of that function (if any).

Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
19 Nov 2011 10:28 AM
I hope you understood that cause I spent a little bit of time on it. :p
Report Abuse
zapzing303 is not online. zapzing303
Joined: 05 Mar 2010
Total Posts: 1486
19 Nov 2011 10:48 AM
Wow... This looks like my first script... You will learn soon! Just keep trying!
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
19 Nov 2011 10:49 AM
NO KLOSE POST
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
19 Nov 2011 10:54 AM
It was very nice of you to explain it for him, ServerLabs. :o
I hope he appreciates the time.
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