You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Nuking
-
What is the issue? So i have lots of if check,And the problem is,It error out that Size is not a valid member of 10,Which is a script,But I’ve added if for if it is a basepart,If it is unanchored which should error out here too and if its position is too far which it should also error out here,But it doesn’t,It only error when the code reach when I’d get the size of the part to compute particle,And my script error at 670.9333333333334 as radius which youll have to look in my code
-
What solutions have you tried so far? Increasing the loop count,By increasing max effect range It seemed that the culprit is the destruction function it self
DESTRUCTION FUNCTION
function Destruction(Pos,Radius)
local function Destroy(Model)
if Model.Name == "Nuke" then return end
for i ,v in ipairs(Model:getChildren()) do
if v:isA("BasePart") and not v:FindFirstAncestor("Nuke") then
if (v.Position-Pos).magnitude < Radius*4 then
if v.Anchored == false then
if game.Players:GetPlayerFromCharacter(v.Parent) then
local dead = game.Players:GetPlayerFromCharacter(v.Parent).codestats["Dead?"]
dead.Value = true
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
game.ReplicatedStorage.Shake:FireClient(plr,1000,3)
game.ReplicatedStorage.Sound:FireClient(plr)
else
local smoke = game.ServerStorage.ParticleEmitter:Clone()
smoke.Parent = script.Parent
--smoke.Enabled = false
local size = {
NumberSequenceKeypoint.new(0,(script.Parent.Size.X +script.Parent.Size.Y +script.Parent.Size.Z )/20);
NumberSequenceKeypoint.new(1,(script.Parent.Size.X +script.Parent.Size.Y +script.Parent.Size.Z )/20);
}
smoke.Size = NumberSequence.new(size)
smoke.Rate = (script.Parent.Size.X +script.Parent.Size.Y +script.Parent.Size.Z )*4
game.Debris:AddItem(smoke,20)
end
v:BreakJoints()
v.Velocity = CFrame.new(v.Position,Pos):VectorToWorldSpace(Vector3.new(math.random(-5,5),5,400))
v.Material = "CorrodedMetal"
deb:AddItem(v,10)
v.Anchored = false
end
end
end
if #v:getChildren() > 0 then
Destroy(v)
end
end
end
Destroy(game.Workspace)
end
local function detonate()
for radiusc = 0, size/speedofsound,1/60 do
--Destruction(script.Parent.Parent.Center.Position,radiusc*speedofsound*3.7)
print(radiusc*speedofsound*3.7)
game["Run Service"].Heartbeat:Wait()
end
connecttion:Disconnect()
end
Any my script that should work did not