So I want to make it so when a player clicks a part, a hinge will appear on the part’s face the player has clicked on. Any ideas on how I can make this possible?
I have a suggestion but I am very new to scripting so sorry for anything I mix up or generally get wrong
- You can create multiple surface GUIs on each face of the part with a transparent button that scaled to the entire face and have a script inside that send info or does anything based on the face you clicked
However, this would mean you need to create the GUIs inside every part but this can be easily done by instancing a surface GUI on every surface on a part for every part in the workspace. Then to have the click detection create a script that detects button pressing and sends info or does what you want, place that script in a storage parent and clone it into each button. The amount of lag or effectiveness would be based on your part count and max players and players in the server. As far as I know the best click detection would be clickdetector but you can’t manipulate it based on the face clicked as far as I know. Let me know if this helps?
How didn’t I think of this! This is a great idea and it perfectly suits my needs. Thank you!
With the use of UserInputService, Camera::ScreenPointToRay and FindPartOnRay - this can be achieved.
Now firstly, you’ll want to get UserInputService like so:
local UserInputService = game:GetService("UserInputService");
Secondly, setup a function which be used for a Connection to InputBegan and check if the UserInputType is MouseButton1 (Left click):
local function InputBegan(Input, Processed)
if (not Processed and Input.UserInputType == Enum.UserInputType.MouseButton1) then
--// Code
end
end
UserInputService.InputBegan:Connect(InputBegan);
Thirdly, inside the function you’ll want to get the Ray from ScreenPointToRay (where you pass the Input.Position’s X and Y) and extend that longer:
local ScreenRay = workspace.CurrentCamera:ScreenPointToRay(Input.Position.X, Input.Position.Y);
local ExtendedRay = Ray.new(ScreenRay.Origin, ScreenRay.Direction * 5000); --// 5k is max length
Finally, get the 4th return value from FindPartOnRay and that’s your Surface:
local Surface = select(4, workspace:FindPartOnRay(ExtendedRay));
my idea is like @AnInspiredGamer but with parts, which may be more helpful because you can move them. create parts around the brick and then set transparency to 1, insert click detectors in each part and then type this code in a server script parented to x part.
ClickDetector = script.Parent.ClickDetector
ClickDetector.MouseClick:Connect(function()
– bla bla
end
this may be more useful because it is easier then doing tons of Instance.New