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: Key Functions Without Tool

Previous Thread :: Next Thread 
camtheman4 is not online. camtheman4
Joined: 30 Jan 2010
Total Posts: 87
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
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
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
camtheman4 is not online. camtheman4
Joined: 30 Jan 2010
Total Posts: 87
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 is not online. 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
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
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
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
11 Aug 2012 10:57 AM
@jlob I didn't know that worked, but it is still a Right click :/
Report Abuse
pingasforce is not online. pingasforce
Joined: 20 Aug 2010
Total Posts: 115
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
camtheman4 is not online. camtheman4
Joined: 30 Jan 2010
Total Posts: 87
11 Aug 2012 11:05 AM
Well how would you do key functions without the tool?
Report Abuse
Jlobblet is not online. 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
pingasforce is not online. pingasforce
Joined: 20 Aug 2010
Total Posts: 115
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
zankonator1 is not online. zankonator1
Joined: 27 Jun 2009
Total Posts: 1758
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
camtheman4 is not online. camtheman4
Joined: 30 Jan 2010
Total Posts: 87
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
pingasforce is not online. pingasforce
Joined: 20 Aug 2010
Total Posts: 115
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
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