I am making a plugin that requires moving when a key is pressed, but when I move something, and then stop it, then move another thing, it moves both of them. Here is my snippet of code. Variables and functions are not the problem.
There are no welds or constraints and are just plain parts.
if find(currentPressed, "Enum.KeyCode.M") and find(currentPressed, "Enum.KeyCode.X") then
canmovey = false
canmove = true
canmovez = false
for i,v in pairs(selected:Get()) do
RunService.RenderStepped:Connect(function()
if canmove == true then
v.Position = Vector3.new(mouse.Hit.X, v.Position.Y, v.Position.Z)
end
end)
end
setPressed()
end
Hey @aven_ue! It moves all parts because you have entered a looped function for i, v in pairs.
That function will get all the children of the object which has same properties resulting in all parts changing their position with respect to the workspace.
To avoid it. Name a specific part you want to move and type object:WaitForChild(“its name”).CFrame.
So its only a block it will work as you wish to move it.