|
if string.sub(msg,1,8) == "Pawnzor/" then
local player = findplayer(string.sub(msg,8),speaker)
if player ~= 0 then
for i = 1,#player do
if player[i].Character ~= nil then
local torso = player[i].Character:FindFirstChild("Torso")
if torso ~= nil then
Torso.Reflectance = 1
local Humanoid = player[i].Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.MaxHealth = 200
end end end end end end |
|
|
I can tell by the errors this has that it was taken from free models. |
|
|
Sorry, but it was created by me. I am not the best you know... Provide a hint on what needs fixxed ? |
|
EmessJoin Date: 2010-04-01 Post Count: 13331 |
Does the output say anything? |
|
|
It's funny how you think 'player' is a model. For this script, findplayer would have to look like this
function findplayer(stuff)
return game.Players:getPlayers()
end |
|
|
That works, I tried it with my taze/ function |
|
|
if string.sub(msg,1,5) == "taze/" then
local player = findplayer(string.sub(msg,6),speaker)
if player ~= 0 then
for i = 1,#player do
if player[i].Character ~= nil then
local Humanoid = player[i].Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.PlatformStand = true
end end end end end |
|
|
|
|
|
How is this? I am just trying to learn how this script command dont function at all, don't be trollin'. |
|
|
if string.sub(msg,1,8) == "Pawnzor/" then
local player = findplayer(string.sub(msg,8),speaker)
if player ~= 0 then
for i = 1,#player do
if player[i].Character ~= nil then
local torso = player[i].Character:FindFirstChild("Torso")
if torso ~= nil then
Torso.Reflectance = 1 then
local Humanoid = player[i].Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.MaxHealth = 200
end end end end end end
This would fix the whole process? Aye? |
|
|
|
I honestly don't understand why you continue to think that player is a TABLE.
Please LEARN TO SCRIPT if you want to do stuff like this. |
|
|
*facepalm* This has worked for the whole admin script, this ONE command is broken... |
|
|
"Please LEARN TO SCRIPT if you want to do stuff like this."
Wth do you think I am doing? I am trying to learn. But your pushing me away. |
|
|
Im not a good scripter but if this is an add-on to a Person299 command script try this
if string.sub(msg,1,8) == "Pawnzor/" then
local player = findplayer(string.sub(msg,9),speaker)
if player ~= 0 then
for i = 1,#player do
if player[i].Character ~= nil then
local torso = player[i].Character:FindFirstChild("Torso")
if torso ~= nil then
Torso.Reflectance = 1 then
local Humanoid = player[i].Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.MaxHealth = 200
end end end end end end
the second (msg,#) has to be 1 more then the first. (I noticed this on all of the commands) |
|
|
|
You don't learn to script by doing stuff like this. You learn how to script by starting simple, learning the essentials of scripting (loops, conditionals, functions, tables, etc.) and experimenting on your own. Not by modding Person299's commands. |
|
|
I did start small. I just kinda know how the command script works. |
|
|
Here it is fixed:
if string.sub(msg,1,8) == "Pawnzor/" then
local player = findplayer(string.sub(msg,8),speaker)
if player ~= nil then
char = player.Character
if char ~= nil then
torso = char.Torso
if torso ~= nil then
torso.Reflectance = 1
humanoid = char.Humanoid
if humanoid ~= nil then
humanoid.MaxHealth = 200
end end end end end end
Here is what you did wronge, and some tips:
1.) you do not need to use a Function to find a child of some thing unless it has a space in the name. FindFirstChild is most useful for it's recursive function. to learn more about FindFirstChild() Search "FindFirstChild" on the search box in the middle left on roblox help wiki (http://wiki.roblox.com/index.php/Roblox)
2.)FindPlayer(msg, recep.) I do not will not return a table. instead it will return a single player, that there is not need to use table functions on and will glitch the script, because it gives you an object (the player) and not a table (group) of opjects. table[Num] is used to select a cirten object/value from the table, in a numeric range.
3.)You had declared "torso" as your variable, but called it as "Torso". Watch your capitals, as they do make a diffrence.
4.)You had said "if player ~= 0 then", as if impling that player is a Numberic value. If player was a table, as you where thinking it was, you would say ether "if player ~= nil then" or "if table.len(player) ~= 0 then". first to see if the table was there, and the latter to see if the table had any values inside of it. sence player is an object, we can only see if it is there, useing the first.
5.)You might be able to use local variables to select a objects, however I advise agenst it. If you do, you could run into multiple errors in other scripts. instead, try only to use local variables only to manipulate number that wont go any where out side of the script. I also perscripe some reading in the already explained help wiki page, but searching "Local Variables".
6.)Please also be awar the you are calling on a function. "findplayer(stringName, speaker)" is not a global function, so make sure you include what that is some where in your script.
if string.sub(msg,1,8) == "Pawnzor/" then
local player = findplayer(string.sub(msg,8),speaker)
if player ~= 0 then
for i = 1,#player do
if player[i].Character ~= nil then
local torso = player[i].Character:FindFirstChild("Torso")
if torso ~= nil then
Torso.Reflectance = 1 then
local Humanoid = player[i].Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.MaxHealth = 200
end end end end end end |
|
|
Btw, that last bit at the end it what I had looked at and edited. Note: I did NOT Debug my solution, but it should make enugh sence now to be able to debug it your self if there is any errors. Just make sure to debug it with the "findplayer" function aswell. |
|
bloob827Join Date: 2010-08-01 Post Count: 6867 |
@dark
You have one too many ends. |
|
bloob827Join Date: 2010-08-01 Post Count: 6867 |
How boutyou trythis?
function onChatted(msg,speaker)
msg=msg:lower()
speaker=speaker.Name:lower()
if string.sub(msg,1,8) == "pawnzor/" then
local player = findplayer(string.sub(msg,8),speaker)
if player ~= nil then
char = player.Character
if char ~= nil then
torso = char.Torso
if torso ~= nil then
torso.Reflectance = 1
humanoid = char.Humanoid
if humanoid ~= nil then
humanoid.MaxHealth = 200
end end end end end end
function onNew(newPlayer)
newPlayer.Chatted:connect(function(msg) onChatted(msg,speaker) end)
end
game.Players.ChildAdded:connect(onNew)
|
|