|
| 11 Aug 2012 10:47 AM |
| Hey everyone, i am making a game called Pokemon Amber, using the wasd keys to move my character. But i also would like to be able to click bricks using "Click Detectors", however, you can't click upon "Click Detectors" while a tool is selected. I would like to know how you could use key functions without having to have a tool selected. Please Help! |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 10:49 AM |
| Instead of using Click Detectors, use mouse.Target instead. That way you can click objects and then carry on a script from there. Much easier than Click detecting I think. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 10:52 AM |
| I have considered that, however it would create alot less work for me using Click Detectors sense all that scripting is already done, i only want to resort to that if i absolutely must. |
|
|
| Report Abuse |
|
|
Jlobblet
|
  |
| Joined: 05 Sep 2010 |
| Total Posts: 587 |
|
|
| 11 Aug 2012 10:55 AM |
Right Clikc a ClickDetector with a tool and you click it, using the usual connection line:
ClickDetector.MouseClick:connect()
~if not ok then return end |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 10:56 AM |
| Well, I don't know of any other way to do this other than using the tool again. And besides, depending on how you have coded the tool it could be as easy as "if mouse.Target.Name == "Tree" then message.Text = "It is a tree" " |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 10:57 AM |
| @jlob I didn't know that worked, but it is still a Right click :/ |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 11:02 AM |
| You can't use tools + left click on click detectors.But it's possible to use keys functions without tools(but you still wont be able to use click detectors Left) |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 11:05 AM |
| Well how would you do key functions without the tool? |
|
|
| Report Abuse |
|
|
Jlobblet
|
  |
| Joined: 05 Sep 2010 |
| Total Posts: 587 |
|
|
| 11 Aug 2012 11:07 AM |
Set the tool to nil, perhaps?
You'd need to equip it to begin with, but apart from that it should work.
~if not ok then return end |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 11:13 AM |
I used this in a local script in backpack
local tool = Instance.new("Tool")
function click(mouse) print("click") end
function select(mouse) tool.Parent = nil mouse.Button1Down:connect(click) end local handle = Instance.new("Part") handle.Parent = tool handle.Name = "Handle" tool.Equipped:connect(select) tool.Parent = script.Parent.Parent.Character |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 11:17 AM |
| When you select the tool, just try to re-parent it, then delete it. I think that's how it goes. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 11:20 AM |
If i did the target thing, i would like to know how i would make it so i could only click when the brick is a certain distance away. what would i change the function to?...
dist = 5
function onClicked() --what would i change this function to??? local p = game.Players:GetChildren() for i = 1, #p do if (p[i].Name ~= script.Owner.Value) then if (p[i].Character.PlayerPart.Head.Position - mouse.Target.Position).magnitude < dist then
blahblah script stuf
end end end end |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 11:29 AM |
Since I don't like usings methods I do things like =
(Circle Zone)
while true do Vector = script.Parent.Position - game.Workspace.Part2.Position Distance = math.abs(Vector.x) + math.abs(Vector.z) print(Distance) if Distance <= 20 then print("Close Enough") end wait(2) end |
|
|
| Report Abuse |
|
|