Hi guys, I need a ctrl + click unanchor part script, I do not know how to do it.
✓ ANSWER ACCEPTED
Ctrl + click unanchor part?
2 answers
✓ Accepted answer
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.
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 :)
This discussion is preserved as it was. New answers, comments, and votes are closed.
