|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
Mr_Crunch
|
  |
| Joined: 16 Jul 2016 |
| Total Posts: 275 |
|
| |
|