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
 

Button1Down event doesn't connect.

Previous Thread :: Next Thread 
Keisuki is not online. Keisuki
Joined: 18 Mar 2011
Total Posts: 239
18 Aug 2012 03:20 AM
All of my tools are controlled by a single script, because they need to use functions and affect variables of that script. However, in this tool, the Button1Down event doesn't connect. When selected, the tool prints "Tool Selected", but when I click, it doesn't print "Mouse Button Pressed".

-----------------------------------

tool = script.Tool:Clone()
tool.Parent = player.Backpack
tool.Selected:connect(function (mouse) print("Tool Selected")
mouse.Button1Down:connect(function () print("Mouse Button Pressed")
if mouse.Target then print("Target Found")
if mouse.Target.Parent:FindFirstChild("Humanoid") then print("Target is a humanoid")
turn(game.Players:GetPlayerFromCharacter(mouse.Target.Parent))
end
end
end)
end)

-----------------------------------

That's all.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
18 Aug 2012 03:24 AM
is it a "Tool" or is it a "HopperBin"?

Tools use.Equipped
HopperBins use .Selected

Don't ask me why.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
18 Aug 2012 03:28 AM
Also, perhaps there are server-client communication failures, because you sound like you know what you're talking about.
If it's a server side script communicating with a client side HopperBin, I bet you that's the problem, and you'll have to make due with something uglier, and I am sure that there is something better than ObjectValues, NumberValues, etc., but I haven't discovered something yet. ( am hoping someone will save me c: )
Report Abuse
awsumpwner27 is not online. awsumpwner27
Joined: 03 Sep 2011
Total Posts: 4389
18 Aug 2012 03:49 AM
--LocalScript version

tool = script.Tool:Clone() --"Tool" assumed to be Hopperbin
tool.Parent = game.Players.LocalPlayer.Backpack --Line only valid in a LocalScript
tool.Selected:connect(function (mouse) print("Tool Selected")
mouse.Button1Down:connect(function () print("Mouse Button Pressed")
if mouse.Target then print("Target Found")
if mouse.Target.Parent:FindFirstChild("Humanoid") then print("Target is a humanoid")
turn(game.Players:GetPlayerFromCharacter(mouse.Target.Parent))
end
end
end)
end)

--Script version

player = game.Players:GetChildren()[1].Backpack --Assumes the use of "PlaySolo"

tool = script.Tool:Clone()
tool.Parent = player
tool.Selected:connect(function (mouse) print("Tool Selected")
mouse.Button1Down:connect(function () print("Mouse Button Pressed")
if mouse.Target then print("Target Found")
if mouse.Target.Parent:FindFirstChild("Humanoid") then print("Target is a humanoid")
turn(game.Players:GetPlayerFromCharacter(mouse.Target.Parent))
end
end
end)
end)

These very slightly modified versions work fine for me. The changed lines have been commented upon. I don't know what could be causing the problem for you though. I don't think it has to do with server-client interaction, since I assume you're using Play Solo, which, as far as I know, only simulates what would happen if you ran the place, except with a player, so there would only be a client.
Report Abuse
Keisuki is not online. Keisuki
Joined: 18 Mar 2011
Total Posts: 239
18 Aug 2012 05:35 AM
Since my place is designed to be a game which works similar to 'Paintball!' LocalScripts cannot be used because they would ruin the game's synchonisation. One person lagging due to bad internet could break the entire script where it tried to ask for a Value object that no longer exists. This would disable the main script and break the entire place.

The second, Script version is useless since I need it for multiplayer not Solo Play.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
18 Aug 2012 05:45 AM
you could also make it deal with it and timeout :P
Dis is a roblox problem, and dey do not fix problems.
Report Abuse
Keisuki is not online. Keisuki
Joined: 18 Mar 2011
Total Posts: 239
18 Aug 2012 08:34 AM
I will try using a tool as opposed to a HopperBin, which may have some difference, then post my result back here.
Report Abuse
Keisuki is not online. Keisuki
Joined: 18 Mar 2011
Total Posts: 239
18 Aug 2012 08:42 AM
When using a tool, and changing the event from 'Selected' to 'Equipped' it failed to connect the Equipped event, Equipping the tool does not cause the script to print that it was selected.
Report Abuse
awsumpwner27 is not online. awsumpwner27
Joined: 03 Sep 2011
Total Posts: 4389
18 Aug 2012 03:40 PM
You did add a brick called "Handle" into the tool though, right?

Also, that one line could easily be changed to get the specific player's backpack:

player = script.Parent.Parent --The Backpack of the player
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