Hey guys.
I have the following script, and yes, it's an nuke. I want it to detect the parts it touches, but it seems like it only works when I press run, and MOVE a part so it touches it. Only then the script works.
Any help?
nuke = script.Parent.CFrame for name, child in pairs(game.Workspace:GetChildren()) do if child:IsA("BasePart") and child.Name ~= "nuke" and child.Name ~= "Baseplate" and child.Name ~= "BasePlate" then child.Anchored = false child:BreakJoints() end end script.Parent.Touched:connect(function(cor) cor.Material = "CorrodedMetal" wait(3) cor:Remove() end) while true do script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1) script.Parent.CFrame = nuke wait() end
The event only registers for touches after the server starts. In other words parts already touching it can't be affected until they disconnect and re-connect to it. You could, however, use the GetTouchingParts
function to determine what base-parts are in contact with your part, but it would only return parts that intersect with yours.
If GetTouchingParts
works for you, you can use it like so
local part = script.Parent for _, touching in pairs(part:GetTouchingParts()) do touching.Material = "CorrodedMetal" ... end