I’m making a preview so you can see where your emplacement is being placed.
This works, but clones something everytime the mouse is moved, but when I move the clone = val:Clone()
line outside of mouse.Move, it doesn’t show up at all.
function PreviewF(val)
local clone
if script.Parent.DigMode.Value ~= true and val ~= nil then
spawn(function()
mouse.Move:Connect(function()
print("this happens")
preview = true
clone = val:Clone()
clone.Parent = game.Workspace
clone:TranslateBy(mouse.Hit.p)
local rotation = CFrame.Angles(0, math.rad(Player.Character.HumanoidRootPart.Orientation.Y), 0)
local modelCFrame = clone:GetPrimaryPartCFrame()
clone:SetPrimaryPartCFrame( modelCFrame * rotation )
for i,v in pairs(clone:GetDescendants()) do
pcall(function()
v.Transparency = 0.5
v.CanColide = false
v.Anchored = true
end)
end
end)
end)
elseif preview == true then
pcall(function()
clone:Destroy()
preview = false
end)
end
end