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: ClickDetectors with FE are local!?

Previous Thread :: Next Thread 
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
02 Sep 2015 02:30 PM
It says it will not be replicated when I click a part with one in. A server script uses it, though.

How do I get past this?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
02 Sep 2015 02:33 PM
Detect the event on the client instead, and use RemoteEvents.
Report Abuse
DermonDarble is not online. DermonDarble
Joined: 04 Jun 2015
Total Posts: 2576
02 Sep 2015 02:40 PM
make your own
Report Abuse
ausmel105 is not online. ausmel105
Joined: 05 Oct 2010
Total Posts: 251
02 Sep 2015 02:44 PM
This uses the local players mouse to detect the click, it's the most efficient way in my opinion.

In the following example I have a remote event in my Workspace named "clickdetector".

So you would put the following code into a local script, in a location which will be transferred to the player. StarterPlayerScripts is probably your best option.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:connect(function()
if mouse.Target then
if mouse.Target.Parent then
if mouse.Target:findFirstChild("ClickDetector") ~= nil then
workspace.clickdetector:FireServer(mouse.Target:findFirstChild("ClickDetector"))
end
end
end
end)

And a script as a child of the clickdetector:

local sp = script.Parent

workspace.clickdetector.OnServerEvent:connect(function(player, object)
if object == sp then
-- STANDARD CODE HERE, WITH THE PLAYER WHO CLICKED BEING "PLAYER"
end
end)

Any questions just ask :)
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
02 Sep 2015 03:13 PM
@aus

that would not work and is completely broken
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
02 Sep 2015 03:53 PM
anyone else? i mean these are good suggestions but i need to see it done.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
02 Sep 2015 03:55 PM
Connect on the client, fire to the Server.
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
02 Sep 2015 03:56 PM
okay eLunate, but how would i detect ANY clickdetector? what kind of setup would I need, or would it be somewhat similar to what that guy said above?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
02 Sep 2015 04:01 PM
LocalScript -> Player -> ClickDetector.Clicky >> FireServer -> OnServerEvent >> Context Code
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
02 Sep 2015 04:01 PM
Create a remote event and when you click the click detector fire the remote event
Report Abuse
ausmel105 is not online. ausmel105
Joined: 05 Oct 2010
Total Posts: 251
02 Sep 2015 05:15 PM
@Deaf

I think you'll find that it does in fact work you should try it before commenting on something without any experience.
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 12:46 AM
aus, it wouldn't work because ClickDetectors don't have OnServerEvent or FireServer.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
03 Sep 2015 12:49 AM
Why use ClickDetectors anyway? They're silly if you ask me, I just prefer doing all that work from mouse.Target
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 12:54 AM
That's a good point, actually. I think I'll make my own kind of clickdetector.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
03 Sep 2015 12:55 AM
Yeah, they're for early in your development life

So much more flexibility with "custom" ones
aka mouse.Target
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 01:00 AM
so would I do a mouse.Button1Down event and check if there's a certain target/object, or use a loop? i'd like to know how to change the mouse cursor too.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
03 Sep 2015 01:02 AM
mouse.Button1Down:connect(function()
local targ = mouse.Target
if targ and targ.Parent and targ.ClassName=="Part" then
-- ogm u click part good job
end
end)


You can also do nifty stuff with this with TargetSurface and UnitRay
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 01:07 AM
Ooh, that could be helpful. Thanks!
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 01:09 AM
But, say I wanted it to change my mouse cursor when I hover over it, would I use a loop or is there an event?
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
03 Sep 2015 01:11 AM
Set up something like this on RenderStepped is what I'd do:

RunService.RenderStepped:connect(function()
local targ = mouse.Target
if targ and targ.Parent and targ.ClassName == "Part" then
-- icon
end
end)
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 01:17 AM
Would it not lag? I don't use those loops often, but I mean it shouldn't as long as I've done it efficiently, right?
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
03 Sep 2015 01:17 AM
For just changing an icon if you're hovering over a part? No reason for it to lag
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
03 Sep 2015 01:19 AM
Ah okay. Thank you!
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