So am just making this little game and… well I need to fire click detector from local script (if it is possible). If it is possible, can anyone tell me the function?
Right now this is the script. It goes through the parts and finds their click detector. Then server sided script does the other work.
mouse.KeyDown:Connect(function(key)
if key == "z" then
local origin = hrp.Position
local direction = hrp.CFrame.LookVector * 30
local raycastPara = RaycastParams.new()
for i, v in pairs(players:GetPlayers()) do
for _, mob in pairs(game.Workspace.Map:GetChildren()) do
raycastPara.FilterDescendantsInstances = {v.Character, mob}
end
end
raycastPara.FilterType = Enum.RaycastFilterType.Blacklist
local result = workspace:Raycast(origin, direction, raycastPara)
if result and result.Instance:FindFirstChildOfClass("ClickDetector") then
print(result.Instance)
game.Workspace.Interactables.Sign.Click.MouseClick()
-- Of course this couldn´t work because it is used to make functionality
end
end
end)