Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The Parent property of land is locked, current parent: NULL, new parent Workspace (how to fix?)

Asked by 5 years ago
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local PosX
local PosY 
local PosZ 
local GridSize = 2 
local isplacing = false
local Model = game.ReplicatedStorage.Models.land:Clone()



local function StartPlacement()

    if not isplacing then
    Model.Parent = game.Workspace
      isplacing = true
    end
end



local function Snap()

    PosX = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize 
    PosY = Model.PrimaryPart.Position.Y
    PosZ = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize 

end



local function Movement()
if isplacing then

    Mouse.TargetFilter = Model 

    Snap() 

    Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ)) 

end
end




Mouse.KeyDown:connect(function(key)
    if key == "x" and isplacing then
        Model:Destroy()
        isplacing = false

    end
end)



script.Parent.MouseButton1Click:Connect(StartPlacement)
Mouse.Move:connect(Movement)


this is a placement system thing when i got the item and press x works good but when i try to get the item again this message pops up --The Parent property of land is locked, current parent: NULL, new parent Workspace-- and idk why

0
Honestly, the way you have things set up is very confusing. The issue is though, that "Model" only gets cloned once for the entire script, so once it's destroyed it's gone permanently. The way to fix that would be to put the "local Model = game.ReplicatedStorage.Models.land:Clone()" into one of the functions so that it gets cloned every time the function is ran. nicktooner 119 — 5y
0
thanks , and sorry for late respond , and sorry for spaghetti code manzano30 5 — 5y

Answer this question