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: ClickDetector LocalScript - FE Issue

Previous Thread :: Next Thread 
CommanderGodfrey is not online. CommanderGodfrey
Joined: 24 Oct 2015
Total Posts: 760
20 Mar 2017 05:35 PM
With a LocalScript as a child of a brick, the code is as follows:

(ClickDetector is at the same hierarchy of the script, so script.Parent.ClickDetector is valid.)

script.Parent.ClickDetector.MouseClick:connect(function()
print("It works!")
end)

This works with a valid Script. However, when switching to LocalScript (because I want to fire a remote event to the server), it does not print my line of code, and it returns no errors either.

I have spent 30 minutes searching for a solution to this, but I have yet to find any concrete solution(s). Has anyone experienced this issue before and found out what they were doing wrong or had to modify? Thanks for the help.
Report Abuse
robloxman303030 is not online. robloxman303030
Joined: 24 Oct 2012
Total Posts: 171
20 Mar 2017 05:42 PM
you could use a local script that checks when a player clicks and if they click that part then u can execute your code.


Report Abuse
CommanderGodfrey is not online. CommanderGodfrey
Joined: 24 Oct 2015
Total Posts: 760
20 Mar 2017 05:42 PM
"you could use a local script that checks when a player clicks and if they click that part then u can execute your code."

That is what I am doing with the ClickDetector.
Report Abuse
FrankieTheDino is not online. FrankieTheDino
Joined: 27 Jul 2008
Total Posts: 603
20 Mar 2017 05:43 PM
I am having this issue too. Some computer are working but some aren't. If anyone have any solutions, please help!


Report Abuse
robloxman303030 is not online. robloxman303030
Joined: 24 Oct 2012
Total Posts: 171
20 Mar 2017 05:45 PM
noo like this local plr = game.Players.LocalPlayer local mouse = ############## local part = workspace.Part #################################### local targ = mouse.Target if targ == part then --code end end)
Report Abuse
Mr_Crunch is not online. Mr_Crunch
Joined: 16 Jul 2016
Total Posts: 275
20 Mar 2017 05:45 PM
yeah i had this problem aswell, but there is a fix.

put the localscript within the playergui and have it control it there so lets say i put my localscript in my playergui

workspace:FindFirstChild("Part"):WaitForChild("ClickDetector").MouseClick:connect(function(hit)
game.ReplicatedStorage.MyEvent:FireServer()
end)
Report Abuse
robloxman303030 is not online. robloxman303030
Joined: 24 Oct 2012
Total Posts: 171
20 Mar 2017 05:46 PM
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local part = workspace.Part

mouse.Button1Down:connect(function()
local targ = mouse.Target
if targ == part then

end
end)



Report Abuse
CommanderGodfrey is not online. CommanderGodfrey
Joined: 24 Oct 2015
Total Posts: 760
20 Mar 2017 05:48 PM
@Mr_Crunch

Putting the script in the StarterGui worked, but I intend on having multiple bricks that you can click on spread across the map. Because of this, how would I go about this with the new solution?
Report Abuse
Mr_Crunch is not online. Mr_Crunch
Joined: 16 Jul 2016
Total Posts: 275
20 Mar 2017 05:58 PM
so you can put all of your clickable parts in a folder and use a loop to be able to click all of them, instead of one by one.

for _,v in pairs(workspace:WaitForChild("ClickableParts"):GetChildren()) do
v.ClickDetector.MouseClick:connect(function(hit)
game.ReplicatedStorage.MyEvent:FireServer()
end)
end)
Report Abuse
CommanderGodfrey is not online. CommanderGodfrey
Joined: 24 Oct 2015
Total Posts: 760
20 Mar 2017 05:59 PM
Thanks a lot, man.
Report Abuse
Mr_Crunch is not online. Mr_Crunch
Joined: 16 Jul 2016
Total Posts: 275
20 Mar 2017 06:06 PM
yeah np anytime.
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