Hello, ive encountered a problem while trying to make a Part respawn in game after ive cloned and destroyed it.
It keeps telling me the parent property is = NUL and is locked
can anyone help?
Heres my code
local RS = game:GetService("ReplicatedStorage")
local AppleTree = game.Workspace.AppleTree
local GApple = RS.AppleTreeFruits.GoldenApple1
local AppleClone = GApple:Clone()
while true do
wait(3)
local function CloneFunction()
GApple.Parent = workspace.AppleTree.Fruits
GApple.Handle.Anchored = true
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
GApple.Handle.Anchored = false
end
end
GApple.Handle.Touched:Connect(PlayerTouched)
wait(5)
print("Droppped")
GApple.Handle.Anchored = false
local Pickedup = false
print("Not picked up")
task.wait(1)
while Pickedup == false do
wait(3)
Pickedup = false
print("Gonna go now")
GApple:Destroy()
if GApple.Parent ~= workspace then
Pickedup = true
print("Picked up by a player, or just dissapeard")
return end
end
end
CloneFunction()
end
I wrapped it in a while loop because i wanted this to always keep running but it seems I’ve come across an error i cant fix on my own. any help would be great Thank you.