Hello!
I am trying to make a game where a disaster is picked and destroys a building with Roblox physics (like Natural Disaster Survival).
However, I’m having an issue with building with welds.
If the primary part is anchored then no single part in the build will detect touches, not even parts welded to an anchored part or further.
I’ve tried making a script continouosly setting the CFrame of the primary part, but that just makes the whole model jitter and knock away players.
Is there a way to fix this? Or is there a replacement I can use instead of anchoring? Do I need a script or is it just a quick checkbox I need to check/uncheck?
Any help appreciated!
1 Like
Are you talking about touch
ing models? Models do not have .Touched
. You may as well have a script, with references to tagged parts, to touch
other parts. Touching anchored parts should not have any issues when touched.
Here is a script example:
local Debounce = false
local ThunderStrikes = game.Workspace.ThunderStrikes:GetChildren()
local TSD = game.Workspace.ThunderStrikes:GetDescendants()
local asset = "14992574745"
local build = script.Parent
local Debounce2 = false
local Debounce3 = false
local Debounce4 = false
local StrikeSFX = game.Workspace.MusicAndSounds.LightningStrikes:GetChildren()
local function StartThunderstorm()
build.Grass.Anchored = false
game.Workspace.DisasterIsland.Baseplate1.CanCollide = false
game.Workspace.DisasterIsland.Baseplate2.CanTouch = true
game.Workspace.Ocean.CanTouch = true
game.Workspace.Cloud.Transparency = 0
while true do
wait(1)
for _,v in pairs(TSD) do
if v and v:IsA("ParticleEmitter") then
v:Destroy()
end
end
for _,v in pairs(game.Workspace:GetChildren()) do
if v and v.Name == "StrikePart" or v.name == "ExplosionPart" then
v:Destroy()
end
end
local TSIndex = math.random(1, #ThunderStrikes)
local rTS = ThunderStrikes[TSIndex]
rTS.Orientation = Vector3.new(180,0,0)
local particle = Instance.new("ParticleEmitter")
particle.Parent = rTS
particle.Rate = 80
particle.Squash = NumberSequence.new(5)
particle.Size = NumberSequence.new(10)
particle.Speed = NumberRange.new(800)
particle.Lifetime = NumberRange.new(100)
particle.LightEmission = 1
particle.Orientation = Enum.ParticleOrientation.FacingCameraWorldUp
local part = Instance.new("Part")
part.Name = "StrikePart"
part.Parent = game.Workspace
part.Position = rTS.Position
part.Size = Vector3.new(1,1,1)
part.Transparency = 1
part.Material = Enum.Material.Neon
part.AssemblyLinearVelocity = Vector3.new(0,-800,0)
local IndexSFX = math.random(1,#StrikeSFX)
local rSFX = StrikeSFX[IndexSFX]
rSFX:Play()
part.Touched:Connect(function(hit)
if hit:IsA("Part") and hit.Name ~= "Cloud" and hit.Name ~= "Thunderstrike" then
if not Debounce2 then
Debounce2 = true
part.Anchored = true
print("Lightning touched")
local explosionPart = Instance.new("Part")
explosionPart.Name = "ExplosionPart"
explosionPart.Parent = game.Workspace
explosionPart.Shape = Enum.PartType.Ball
explosionPart.Size = Vector3.new(45,45,45) --CHANGE SIZE HERE
explosionPart.Anchored = true
explosionPart.Position = part.Position
explosionPart.Material = Enum.Material.Neon
explosionPart.BrickColor = BrickColor.new("Institutional white")
explosionPart.CanCollide = true
explosionPart.CanTouch = true
explosionPart.CanTouch = true
explosionPart.Touched:Connect(function(hit)
if not Debounce3 then
Debounce3 = true
local hum = hit.Parent:FindFirstChild("Humanoid")
if hit.Parent == build and (hit:IsA("Part") or hit:IsA("UnionOperation") or hit:IsA("MeshPart") or hit:IsA("BasePart")) and hit.Name ~= "Grass" and hit.Name ~= "FloorBase" then
local welds = hit:GetChildren()
for _,v in pairs(welds) do
if v and (v:IsA("Weld") or v:IsA("WeldConstraint")) then
v:Destroy()
end
end
end
for _,v in pairs(game.Players:GetChildren()) do
if v then
local char = v.Character
local hrp = char:FindFirstChild("HumanoidRootPart")
if hrp then
hrp.AssemblyLinearVelocity = Vector3.new(3,0,3)
end
end
end
Debounce3 = false
end
end)
wait(0.4)
for i = 0, 1 ,0.2 do
wait(0.05)
explosionPart.Transparency = i
end
wait(0.1)
explosionPart:Destroy()
particle:Destroy()
part:Destroy()
Debounce2 = false
end
end
end)
end
end
local function ConnectToTornado()
local ThunderstormEvent = game.ReplicatedStorage.SelectedDisasters:FindFirstChild("Thunderstorm")
if ThunderstormEvent and ThunderstormEvent:IsA("RemoteEvent") then
if script.Parent.Parent == game.Workspace.ShownMaps then
if not Debounce then
Debounce = true
StartThunderstorm()
end
end
end
end
game["Run Service"].Heartbeat:Connect(function()
ConnectToTornado()
end)
It does do it correctly, but if the grass model is “anchored = true” then it does not detect it or parts welded to it. But the other part touching it is anchored too, so the thing I need to do is to not anchor those parts? How can I replace it with “anchored = true”?
Because if I have it unanchored it might jitter through collision and “CanCollide = false” disables touch detecting, too.
Basically I don’t know how to get a replacement for anchoring without jittering and glitchy physics when using unanchored.