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 » Scripters
Home Search
 

Re: Tool only works once, then stops working?

Previous Thread :: Next Thread 
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 10:22 AM
For some reason, after the first use, which works fine, my tool no longer changes the BoolValue in a player to Is_Zip_Tied's value to false, but there are no errors

This is my script inside of the tool

repeat wait() until game.Players.LocalPlayer.Character
repeat wait() until game.Players.LocalPlayer.Character.Parent == workspace

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character
local debounce = false

local disposableConnections = {}

function newDisposableConnection(connection)
table.insert(disposableConnections, connection)
end

function disposeOfConnections()
for i, v in pairs(disposableConnections) do
v:disconnect()
end
disposableConnections = {}
end

function unbind(player)
local zipVal = player:findFirstChild("Is_Zip_Tied")
if zipVal ~= nil then
zipVal.Value = false
else
local val = Instance.new('BoolValue', player)
val.Name = 'Is_Zip_Tied'
val.Value = false
end
end

tool.Equipped:connect(function(mouse)
newDisposableConnection(mouse.Button1Down:connect(function() mouse_is_down = true end))
newDisposableConnection(mouse.Button1Up:connect(function() mouse_is_down = false end))
newDisposableConnection(game:GetService("RunService").RenderStepped:connect(function()
script.Parent.Handle.Touched:connect(function(obj)
local humanoid = obj.Parent:findFirstChild("Humanoid")
if not debounce and mouse_is_down and obj.Parent ~= character and humanoid ~= nil then
debounce = true
local hitPlayer = obj.Parent
unbind(hitPlayer)
end
end)
end) )
end)

tool.Unequipped:connect(disposeOfConnections)






-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 10:23 AM
Also please note that Is_Zip_Tied is inserted into every character upon spawning in another script, so it's always present


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 10:41 AM



-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 10:50 AM
bump


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 11:20 AM
...


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 11:44 AM



-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 12:09 PM
adsfgb


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 12:28 PM
grr


-Widths
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
09 Apr 2015 12:45 PM
May not be the reason, but why this?

newDisposableConnection(game:GetService("RunService").RenderStepped:connect(function()

Wouldn't that just loop create the event?


~ 1Topcop ~ WebGL3D ~ Java3D ~ Data3D ~ Purple Squid >
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 12:48 PM
idk, foreverdev told me to do that
i removed it but i still have the same issue


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 01:06 PM
gah


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 01:20 PM
rip


-Widths
Report Abuse
iJava is not online. iJava
Joined: 06 Mar 2011
Total Posts: 29914
09 Apr 2015 01:22 PM
*facepalm* I never made debounce false again...


-Widths
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
09 Apr 2015 01:23 PM
lol

-=Robo=-
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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