ninja5566
|
  |
| Joined: 14 Jan 2009 |
| Total Posts: 5233 |
|
|
| 06 Oct 2012 10:46 PM |
player = script.Parent.Parent.Parent.Parent.parent
function chat(msg) if msg == "clear" then c = player.StarterGear.GetChildren() c:Destroy() local M = Instance.new("Message") M.Parent = player.Character.Torso M.Text = "Tools cleared!"
else
local b = Instance.new("Message") b.Text = "An error has occured" end end
game.Player.PlayerAdded:connect(chat)
this script is very simple alls it does is for my gear gui testing game when you say "clear" it clears all your gears from your backpack and starterGear but it isn't working, please help. |
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 10:47 PM |
This script looks like it goes in the Player, so PlayerAdded won't fire because the Player already Spawned.
Plus You forgot to Capitalise P in the last Parent |
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 10:48 PM |
player = script.Parent.Parent.Parent.Parent.Parent --Last Parent should be capitilized function chat(msg) if msg == "clear" then player.BackPack:ClearAllChildren() player.StarterGear:ClearAllChildren() --These methods are easier for what you're doing local M = Instance.new("Message") M.Parent = player.Character.Torso M.Text = "Tools cleared!" else local b = Instance.new("Message") b.Text = "An error has occured" end end game.Player.PlayerAdded:connect(chat)
¤ ¤ † K M X D † ¤ ¤
|
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 10:50 PM |
Eh, after a second look...
function Added(player) player.Chatted:connect(function(msg) if msg == "clear" then player.BackPack:ClearAllChildren() player.StarterGear:ClearAllChildren() --These methods are easier for what you're doing local M = Instance.new("Message") M.Parent = player.Character.Torso M.Text = "Tools cleared!" else local b = Instance.new("Message") b.Text = "An error has occured" end end) end game.Players.PlayerAdded:connect(Added)
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 10:50 PM |
| ClearAllChildren() uses :Remove |
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 10:54 PM |
. . .
Game.Players.PlayerAdded:connect(function(Player) Player.Chatted:connect(function(Chat) if Chat == "clear" then Player.BackPack:ClearAllChildren() Player.StarterGear:ClearAllChildren() local Message = Instance.new("Message", Player.PlayerGui) Message.Text = "Tools cleared!" wait(3) Message:Destroy() else local Message = Instance.new("Message", Player.PlayerGui) Message.Text = "An error has occurred" wait(3) Message:Destroy() end end) end)
@Chop
I think it'd still be better than to use loops.
¤ ¤ † K M X D † ¤ ¤
|
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 10:55 PM |
BackPack should also be Backpack.
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
ninja5566
|
  |
| Joined: 14 Jan 2009 |
| Total Posts: 5233 |
|
|
| 06 Oct 2012 11:07 PM |
| Thanks for trying to help but it did not help, I put the script in the StarterGui |
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 11:11 PM |
Put it in Workspace. Remember to change "BackPack" to "Backpack".
¤ ¤ † K M X D † ¤ ¤ |
|
|
| Report Abuse |
|
|
ninja5566
|
  |
| Joined: 14 Jan 2009 |
| Total Posts: 5233 |
|
|
| 06 Oct 2012 11:14 PM |
| Thanks! Worked perfectly fine. Can you help me understand the changes you made though so I can learn from my mistake? |
|
|
| Report Abuse |
|
|
|
| 06 Oct 2012 11:19 PM |
player = script.Parent.Parent.Parent.Parent.parent --Not needed if use use the PlayerAdded event and it's argument function chat(msg) --This function is connected to the PlayerAdded event, instead of the Player's Chatted event if msg == "clear" then c = player.StarterGear.GetChildren() --You can't simply do that, as it would return a table, and it should be :GetChildren() c:Destroy() local M = Instance.new("Message") M.Parent = player.Character.Torso --Not sure if it would make the message local, so I used PlayerGui M.Text = "Tools cleared!" else local b = Instance.new("Message") --Didn't parent the message b.Text = "An error has occured" --Both wouldn't remove the messages end end game.Player.PlayerAdded:connect(chat)
¤ ¤ † K M X D † ¤ ¤
|
|
|
| Report Abuse |
|
|