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

Deleting this brick without locking its parent?

Asked by
emite1000 335 Moderation Voter
10 years ago

An expansion of my previous question, which was starting to have people give me scripts because I didn't post my own script.

I have a script here that clones a drop and positions it like it is falling of a pipe. When the droplet hits the floor (a brick named puddle), it is supposed to disappear. However, I am using the destroy method to make it disappear, and that is causing the droplet's parent (Workspace) to become "locked". Every time the script tries to loop and spawn the second droplet, it can't and gives the output "****The Parent property of Droplet is locked****"

How do I make it so that when the droplet is destroyed, the parent isn't locked?

Little = Workspace.Drop:Clone()
while true do
    Little.Parent = Workspace
    Little.Position = Vector3.new(81.3, 7.3, 99.1)
    Little.Name = "Droplet"
    Little.Touched:connect(function(part)
        if part.Name == "Puddle" then
            Little:Destroy()
        end
    end)
wait(5)
end
0
You can't. :Destroy() removes it from the game, so you can't get it back. Nickoakz 231 — 10y
0
No. All that is being destroyed is the drop's Clone. The clone has nothing in it or attached to it and is a child of Workspace. I don't want back because I am just going to create another in 5 seconds. emite1000 335 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

I would use Little:remove() or Little = nil because Little:Destroy() removes is completely from the game, so it won't be possible to clone it.

Litte = game.Lighting.Drop --Drop MUST be in workspace
while true do
Little:Clone()
Little.Parent = Workspace
Little:remove()
wait() -- makes sure that studio doesn't crash
end

-- HOPE THIS HELPED :)
0
1: Little isn't being cloned. Drop is. 2: Little = nil doesn't work because then it just becomes a nil value and sits there, but doesn't disappear. 3, Litle:Remove() works the first time, but then every other time the part spawns it doesn't disappear. emite1000 335 — 10y
0
Just edited the code, this should work :) fahmisack123 385 — 10y
0
Your new script doesn't make any sense. You are making a clone but not giving it a parent location to spawn in. All you are doing is telling the Drop to parent itself to the workspace.... which it already is. Then you are removing the drop instantaneously after that. emite1000 335 — 10y
0
Wait, I forgot, Little was meant to be in Lighting... Sorry fahmisack123 385 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Try doing Little.Visibility = 1 That way it only appears that the droplet is gone, but really you still have it ready to be used again. Or, you could clone it before you remove it, with Little:Clone().Parent = What you want it's parent to be

Answer this question