allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
|
| 22 Aug 2014 01:00 PM |
I have an ImageButton in my game which when Left-clicked gives the "Paint" tool, and when right-clicked removes the "Paint" tool from a player's toolbar. In total I have 11 of these tool buttons. Currently, I'm trying to make a "Remove all Tools" button which deletes every build tool from the player's toolbar when clicked.
I'm just testing it with the "Paint" tool right now. The GUI button works fine, until you click the remove all tools button, at which point it breaks and no longer gives you the "Paint Tool". Not really sure why it's acting up like this. Any help is greatly appreciated.
Paint Tool Giver ImageButton localscript: plr = game.Players.LocalPlayer tool = game.Lighting["Paint"] myBoolValue = plr["paintbool"].Value
function myToolGiver() if myBoolValue == false and plr.Backpack:findFirstChild("Paint") == nil then tool:clone().Parent = plr.Backpack myBoolValue = true end end
function myToolRemover() if myBoolValue == true and plr.Backpack:findFirstChild("Paint") ~= nil then game.Players.LocalPlayer.Backpack["Paint"]:remove() myBoolValue = false end end
function borderMaker() wait(0.1) if myBoolValue == true then script.Parent.BackgroundTransparency = 0 end end
function borderRemover() wait(0.1) if myBoolValue == false then script.Parent.BackgroundTransparency = 1 end end
script.Parent.MouseButton1Down:connect(myToolGiver) script.Parent.MouseButton2Down:connect(myToolRemover) script.Parent.MouseButton1Down:connect(borderMaker) script.Parent.MouseButton2Down:connect(borderRemover)
Remove all Tools localscript (currently only testing with paint tool): plr = game.Players.LocalPlayer
function removeAllTools() if plr.Backpack:findFirstChild("Paint") ~= nil then plr.Backpack["Paint"]:remove() plr["paintbool"].Value = false plr.PlayerGui.Toolbar.Frame["Paint Tool Button"].BackgroundTransparency = 1 end end
script.Parent.MouseButton1Down:connect(removeAllTools)
And there is a BoolValue named "paintbool" inside the player. Any advice as to why this is breaking? Thanks. |
|
|
| Report Abuse |
|
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
| |
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
| |
|
Mitko0o1
|
  |
| Joined: 30 Nov 2010 |
| Total Posts: 5725 |
|
|
| 23 Aug 2014 04:15 AM |
| I like it when someone pastes a large script and expects people to inspect it and find the smallest mistake he made in it. |
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
|
| 23 Aug 2014 04:18 AM |
yeah ikr. but i can answer the question of removing a player's inventory.
use a for loop. LOL |
|
|
| Report Abuse |
|
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
|
| 23 Aug 2014 05:25 AM |
Err, okay, I don't expect you to do anything, and if you don't want to help, there's no point posting :S if I thought that I knew where the error was, I would not post the entire script, but since I don't, what am I supposed to do? It's really not that much script anyway. Thanks for the commentary though.
@roblok1 so do you mean like: for plr.Backpack:findFirstChild("Paint") ~= nil do
rather than if and then? I'm not sure how the for loop works. |
|
|
| Report Abuse |
|
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
| |
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
| |
|
|
| 23 Aug 2014 10:56 AM |
event tool:clone().parent=plr.BackPack end |
|
|
| Report Abuse |
|
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
|
| 23 Aug 2014 11:36 AM |
| Yep, that's already in the script for the button. |
|
|
| Report Abuse |
|
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
|
| 23 Aug 2014 12:06 PM |
I've simplified the script. Hopefully this should make it a lot clearer.
Paint tool button: plr = game.Players.LocalPlayer tool = game.Lighting["Paint"] myBoolValue = plr["paintbool"].Value
function myToolGiver() if myBoolValue == false and plr.Backpack:findFirstChild("Paint") == nil then tool:clone().Parent = plr.Backpack wait(0.1) myBoolValue = true script.Parent.BackgroundTransparency = 0 end end
function myToolRemover() if myBoolValue == true and plr.Backpack:findFirstChild("Paint") ~= nil then game.Players.LocalPlayer.Backpack["Paint"]:remove() wait(0.1) myBoolValue = false script.Parent.BackgroundTransparency = 1 end end
script.Parent.MouseButton1Down:connect(myToolGiver) script.Parent.MouseButton2Down:connect(myToolRemover)
Remove all Tool button: plr = game.Players.LocalPlayer
function removeAllTools() if plr.Backpack:findFirstChild("Paint") ~= nil then plr.Backpack["Paint"]:remove() plr["paintbool"].Value = false plr.PlayerGui.Toolbar.Frame["Paint Tool Button"].BackgroundTransparency = 1 end end
script.Parent.MouseButton1Down:connect(removeAllTools) |
|
|
| Report Abuse |
|
|
allers
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 27 |
|
|
| 23 Aug 2014 12:18 PM |
| Okay, I've fixed it now. Thanks anyway. |
|
|
| Report Abuse |
|
|