so i have a game and in that game there is a dead bush.
now i want the dead bush to respawn after players destroyed it for resources but it doesn’t respawn.
when i went to check what’s wrong, the code looked fine.
so i had it print the exact moments and even checked if the model had spawned.
when i went to go check i saw that the model was spawned, but it was empty…
why?
picture of problem:
here is the script:
local Bushes = script.Parent.Parent.Bushes
local Pos = Bushes.Bush.MAIN.Position
Bushes.ChildRemoved:Connect(function(child)
print("Ran")
task.wait(60)
print("Awaited")
local Bush = game.ServerStorage.Bush:Clone()
Bush.Parent = script.Parent.Parent--forgor to add .Bushes just ignore :)
Bush:PivotTo(CFrame.new(Pos))
end)
so any way how to fix this?
i’ve already tried restarting rblx studio but that doesn’t seem to help…
the bush itself does not contain any scripts, but it can be destroyed by the script of a player’s tool.
the bush contains only two attributes which say health and drops but that’s it.
so i really don’t know what is wrong
this is a sample of the touched event for the player’s tool:
Folder.Hammer.Touched:Connect(function(hit)
if not IsHitting then return end
if hit.Parent == Character then return end
if not hit:GetAttribute("Health") then return end
hit:SetAttribute("Health",hit:GetAttribute("Health") - Damage)
Tool:SetAttribute("Durability",Durability - 1)
Durability = Tool:GetAttribute("Durability")
IsHitting = false
HitSFX:Play()
if hit:GetAttribute("Health") <= 0 then
if hit.Parent:IsA("Model") then
--Code which chooses drops
hit.Parent:Destroy()
--Rest of code which drops the items...
else
hit:Destroy()
end
end
end)
Hm, the Bush in game.ServerStorage.Bush is most like empty. If in Studio it is not then there is some script clearing its children.
add this line
local Bush = game.ServerStorage.Bush:Clone()
print(#Bush:GetDescendant()) -- add this line
If that prints 0, then you know the Bush in ServerStorage is empty. If it is more than 0 than there is something else clearing the descendants of the cloned Bush.
for anyone who just arrived, i’ve opened a new place and started to slowly copy paste everything from the first to the second place, every time i pasted something i tested if the bush still works.
at the beginning it worked and eventually i added everything!
(sike otherwise i wouldn’t be here)
when i went ahead and added the last item,
it broke.
that item was a script.
this to be exact:
local L = game.Lighting
local Days = 0
game.Players.PlayerAdded:Connect(function(plr)
local Connection = nil
task.wait(5)
local Folder = game.ServerStorage.Islands
local IslandNumber = math.random(1,#Folder:GetChildren())
local Island = Folder.Island3:Clone() --Folder:GetChildren()[IslandNumber]:Clone()
Island.Parent = workspace
local Position = Vector3.new(math.random(1,10000),50,math.random(1,10000))
Island:PivotTo(CFrame.new(Position))
plr.Character.PrimaryPart.Position = Island.Start.Position
Island.Name = plr.Name.."'s Island!"
plr.CharacterRemoving:Connect(function(char)
task.wait(0.1)
plr.Character.PrimaryPart.Position = Island.Start.Position
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local Island = workspace:FindFirstChild(plr.Name.."'s Island")
if not Island then return end
Island:Destroy()
end)
while wait(20) do
L.ClockTime += 1
end
i’ve narrowed the problem down from, the entirety of game to this.
i still don’t know what line causes this, if a copy of the island3 is already in the game the island3 model that get’s spawned will also break but the bush on the first island will work.
if there is no copy of island3 already in the game, the spawned island3 will work but the bush breaks.
now keep in mind , the pre made copy and the model in ServerStorage are the same, since i’ve pressed ctrl+c + ctrl+v