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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|