Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ctrl + click unanchor part?

Asked by 6 years ago

Hi guys, I need a ctrl + click unanchor part script, I do not know how to do it.

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hey, what AlexTheCreator said is a way to do it, but not the 'right' way. What you need to do is make a LocalScript, put it in StarterGui or StarterPlayer>StarterPlayerScripts. You need to put this code in the script:


local Mouse = game:GetService("Players").LocalPlayer:GetMouse() local UIS = game:GetService("UserInputService") local CTRLisBeingPressed = false UIS.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.LeftControl then CTRLisBeingPressed = true end end) UIS.InputEnded:connect(function(input) if input.KeyCode == Enum.KeyCode.LeftControl then CTRLisBeingPressed = false end end) Mouse.Button1Down:connect(function() if CTRLisBeingPressed == true then local Obj = Mouse.Target; local unanchor = Obj.Anchored if unanchor ~= nil then Obj.Anchored = false end end end)

If you have any other questions, please tell me.

Ad
Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

I'm pretty new but I think you should use the UserInputsService (or https://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan) to detect when the CTRL button is being held and then detect if the block has been clicked using a ClickDetector :)

Answer this question