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: Tool Giver Issue

Previous Thread :: Next Thread 
allers is not online. 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 is not online. allers
Joined: 17 Feb 2009
Total Posts: 27
22 Aug 2014 01:37 PM
bump
Report Abuse
allers is not online. allers
Joined: 17 Feb 2009
Total Posts: 27
23 Aug 2014 04:13 AM
bump
Report Abuse
Mitko0o1 is not online. 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 is not online. 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 is not online. 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 is not online. allers
Joined: 17 Feb 2009
Total Posts: 27
23 Aug 2014 09:45 AM
bump
Report Abuse
allers is not online. allers
Joined: 17 Feb 2009
Total Posts: 27
23 Aug 2014 10:53 AM
bump
Report Abuse
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
23 Aug 2014 10:56 AM
event
tool:clone().parent=plr.BackPack
end
Report Abuse
allers is not online. 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 is not online. 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 is not online. allers
Joined: 17 Feb 2009
Total Posts: 27
23 Aug 2014 12:18 PM
Okay, I've fixed it now. Thanks anyway.
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