I'm making a build preview and I need help with the last part of this script. Right now It makes a clone of the object I want to place, and it moves wherever the mouse is then places it when I click on a part named "Allowed1" otherwise it wont place. Anyway, when the mouse is over Allowed1 it places correctly but then it continues to follow the mouse. How would I make the part stop following the mouse and stay where I clicked? Thanks! (Also if you know how I could fix it so it rotates too that would help if not its ok ..)
local player = game.Players.LocalPlayer;
local mouse = game.Players.LocalPlayer:GetMouse();
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local b = game.ReplicatedStorage:WaitForChild("Headquarters")
local clickdetector = game.Workspace:WaitForChild("Outline"):WaitForChild("ClickDetector")
local HQ = b:Clone()
target = mouse.Target
---------------------------------------------------------------------
---------------------------------------------------------------------
function temp ()
b:Clone()
HQ.Parent = workspace.Buildings
for i,child in pairs(HQ:GetChildren()) do
if child:IsA("BasePart") then
child.Transparency = 0.5
function onKeyDown(key)
if child then
key = key:lower() --Not working for some reason..
if key == 'r' then
child:AxisRotate(Enum.Axis.Y) --Rotate
elseif key == 't' then
child:AxisRotate(Enum.Axis.Z)
end
end
end
end
end
------------------------------------------------------
-------------------------------------------------------
mouse.Move:connect(function()
local child = workspace.Buildings.Headquarters
child:MoveTo(mouse.hit.p)
end)
mouse.Button1Down:connect(function ()
mouse.TargetFilter = HQ
print (mouse.Target)
if mouse.Target ~= nil and mouse.Target.Name == "Allowed1" then -- Where you can build on
print "Allowed"
print "Placed"
for i, child2 in pairs(HQ:GetChildren()) do
child2.Transparency = 0
--Set child2 position here....Help
end
end
if mouse.Target.Name == "NotAllowed1" or mouse.Target == nil then --What you dont what the building to be placed on
print "Not Allowed"
selected = ""; --Doesnt allow it to be placed
end;
end)
end
clickdetector.MouseClick:connect (temp)

2 comments
is it a local script or not?
Yes its a local script