What are you trying to achieve?
I’m trying to achieve when can you detect when player clicking a something on client.
Can you elaborate what are you saying?
Alright so, when you use clients and use it for Click Detector, in Hard way, detecting click detectors in client, client is on StarterGui so the client will check every things on workspace, it it founds click detector, it will use the events and modify it
This is example of I scripted an PromixityPromptService, so I modify it so it looks good now.
I’m making a horror game. Anyways,
Is there way to modify the ClickDetector in clients? Just like how I modified the Promixity Prompt Service I wanna know it.
I don’t think you can modify ClickDetectors on the Client besides changing it’s Activation Distance/Mouse Icon. I think you could just stay with ProximityPromptService like how it is.
I did a Interaction system a long time ago that u doing now , I used this “module” that i found To See if Mouse is hovering a Part
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local class = {}
--[[ Parameters:
distance (number): the distance from the camera that the method will look for a part. Leave as nil to have no set distance.
ignore (table): the list of objects (descendants of objects in this list as well) that will be ignored.
ignoreInvisible (boolean): if true, when there is a part with transparency of 1 in the path of the mouse's target, it will be added to the ignore list.
ignoreCantCollide (boolean): if true, when there is a part with cancollide set to false in the path of the mouse's target, it will be added to the ignore list.
]]
class.getTarget = function(distance,ignore,ignoreInvisible,ignoreCantCollide)
if not mouse.Hit then return end
ignore = ignore or {}
local function scan()
local ray = Ray.new(camera.CoordinateFrame.p,(mouse.Hit.p - camera.CoordinateFrame.p).unit*(distance or 900))
if ignore[1] then end --print("ignore:",ignore[1]) end
return workspace:FindPartOnRayWithIgnoreList(ray,ignore)
end
local complete = false
local hit,pos = scan()
repeat
if not hit or not pos then return end
if (ignoreInvisible and hit.Transparency == 1) or (ignoreCantCollide and not hit.CanCollide) then
table.insert(ignore,hit)
hit,pos = scan()
else
complete = true
end
until complete
for i,part in pairs(ignore) do
print(part.Name)
end
return hit,pos
end
_G.CustomMouse = class
Altought This is A LocalScript that you need to put in StarterPlayerScripts
Really easy to achieve this, just check that the client (for which the local script is executing for) matches the player instance that clicked the ClickDetector instance.
local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local part = workspace:WaitForChild("Part")
local click = part:WaitForChild("ClickDetector")
click.MouseClick:Connect(function(player)
if localPlayer == player then
print("Hello world!")
end
end)