Hi, I'm making a build preview and everything works fine now except the part continues to rotate after being placed if you keep pressing "r". How do I disconnect the function which makes it rotate?
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local blankPart = game.ServerStorage:WaitForChild('WoodWall')
script.Parent.MouseButton1Down:connect(function()
if player.leaderstats.Wood.Value >= 5 then
player.leaderstats.Wood.Value = player.leaderstats.Wood.Value - 5
script.Parent.Parent.Parent.Parent.Visible = false
local part = blankPart:Clone()
mouse.TargetFilter = part
moveConn = mouse.Move:connect(function()
local p = mouse.Hit.p
part.Position = Vector3.new(math.floor(p.X),math.ceil(p.Y),math.floor(p.Z))
mouse.KeyDown:connect(function(key)
if (key == "r") then
part.CFrame = part.CFrame*CFrame.Angles(0,math.pi/2,0)
end
end)
end)
mouse.Button1Down:wait()
moveConn:disconnect()
mouse.KeyDown:disconnect(key)
end
end)

1 comment
Thanks for the help! I have it working now!!