mouse = game.Players.LocalPlayer:GetMouse()
player = game.Players.LocalPlayer
local clone = game.Workspace.turret:Clone()
mouse.Move:connect(function()
if mouse.Target ~= nil then
if mouse.Target.Name == "m" then
clone.Parent = game.Workspace
clone.Anchored = true
clone.CanCollide = false
clone.Position = mouse.Target.Position + Vector3.new(0,1,0)
else clone:Destroy()
end
end
end)
it's supposed to make a part be cloned and put on top of a part when my mouse moves over it heres the error:
The Parent property of turret is locked, current parent: NULL, new parent Workspace line 8
What? if i take out the else part, it works fine, but then the part stays on the last part called 'm' that mouse was on. so why doesn't it work with the else?

3 comments
It's because you destroy the clone on line 12 when the if statement is false. Therefore when the if statement of line 7 is true the clone is parented and locked to nil.
oh, so how do i fix it, if it gets put at nil when the clone is destroyed?
Sorry about the long wait, try it now, i added an elseif on line 12 that might help. Hopefully we can get it working