the thing is, i dont think its misplaced, because i started with 1 part and tested it a few time and it worked, and these buildings were made from copy and pasting that part
Denial can lead to the cause. Just see if you can find something, itās likely you just misplaced a specific script.
The script isnāt the issue from what I tested myself, it has to be the position of the script affecting it
i found it! lemme test if it happens again
Alright, letās hope that fixed the issue!
Glad to know you found it! Let us know if the problem persists
It fixed it! tysm guys, ive had this problem for so long and had to seal off this part of the game because i didnt know how to fix it!, can you help me with one more thing? i want the broken apart parts to become uncollideable after a few seconds otherwise itll cause lag. can you help me
you can also do
āv.CanCollide = falseā
just at the bottom of the script? and with a wait (20) above it right?
in this part of the script;
for i, v in pairs(script.Parent.Parent:GetChildren()) do
if not v:IsA("BasePart") then continue end
v.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(197, 196, 199)
smoke.Opacity = 0.25
smoke.RiseVelocity = 6
end
āv.CanCollide = falseā inside the for loop.
The issue with what @Wyzloc stated is that a method like that may cause some parts to fall out of the world since they are uncollideable, meaning they can fall through the world. If you want to make it so once something is destructed, donāt have any collisions with certain things, you could try learning about CollisionGroups. But generally the main thing is that a lot of physics will lag the game, although there definitely are some ways to optimize it
thats why i want to make it fall through the world, itll be, you destroy it, some effects playout, after while the parts will fall away. i have an automatic every 5 min regen script that regens certain parts every 5 minutes including this building.
Ohhh, I see. Sorry that I misunderstood the question. Then yea, I think their method should work for you
i added it to the script but now not the whole model gets unanchored and some parts only cancollide off and the smoke doesnt stop emitting, script:
local ready = true
local sound = script.Parent.SoundāChange to your sound location.
local delaytime = 5
script.Parent.Touched:Connect(function()
if ready == true then
ready = false
for _, v in pairs(script.Parent.Parent:GetChildren()) do
v.Anchored = false
local smoke = Instance.new(āSmokeā)
smoke.Parent = v
smoke.Color = Color3.new(197, 196, 199)
smoke.Opacity = 0.25
smoke.RiseVelocity = 6
wait (15)
v.CanCollide = false
end
sound:Stop()
sound:Play()
wait(delaytime) -- Amount of till making smoke dissapear
for i, v in pairs(script.Parent.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Smoke:Destroy()
end
end
script:Destroy()
ready = true
end
end)
why donāt you clone the objects then, and have it respawn after being destroyed. like this for example:
local building = workspace.BuildingName
local Duration = 30 -- 30 seconds till buildings back
for _,v in pairs(building:GetChildren()) do
if v:IsA("BasePart") then
v:SetAttribute("OldTransparency", v.Transparency)
v.Transparency = 1 -- making sure nobody can see the real one
local part = v:Clone()
part.CanCollide = false
part.Anchored = false
part.CFrame = v.CFrame
part.Parent = v.Parent
game.Debris:AddItem(part, 30)
end
end
wait(Duration)
for _,v in pairs(building:GetChildren()) do
if v:IsA("BasePart") then
local OldTransparency = v:GetAttribute("OldTransparency")
if OldTransparency then
v.Transparency = OldTransparency
end
end
end
thank you but i like my current regen system, i just have the problem listen above ur msg
I wasnāt trying to replace your script I was just giving an example of how it would be done through another personās perspective.
Anyways itās pretty hard to figure out what the problem is when you donāt show any gifs, or examples of what youāre experiencing.
Your issue is that it sets the properties of one part and then yields 15 seconds before going to the next, try this
local ready = true
local sound = script.Parent.Sound--Change to your sound location.
local delaytime = 5
script.Parent.Touched:Connect(function()
if ready == true then
ready = false
for i, v in pairs(script.Parent.Parent:GetChildren()) do
if not v:IsA("BasePart") then continue end
coroutine.wrap(function()
v.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(197, 196, 199)
smoke.Opacity = 0.25
smoke.RiseVelocity = 6
wait(15)
v.CanCollide = false
end)()
end
sound:Stop()
sound:Play()
wait(delaytime) -- Amount of till making smoke dissapear
for i, v in pairs(script.Parent.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Smoke:Destroy()
end
end
script:Destroy()
ready = true
end
end)
This will wrap each in their own thread so the wait doesnāt affect the loop
i did this and it unanchored everything again and stopped the smoke but didnt uncollideable the parts after 15 seconds, edit: what i mean with unanchored everything again is that it unanchored everything thats needed to be unanchored so not the whole map, just to clarify lol
Hmm, try changing the Coroutine.wrap code to
coroutine.wrap(function()
local part = v
part.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(197, 196, 199)
smoke.Opacity = 0.25
smoke.RiseVelocity = 6
wait(15)
print("UnColliding Part")
part.CanCollide = false
end)()
Edit: It could also be that the script is being destroyed before the 15 seconds are up, try increasing the delay