Hello Developer/Helpers,
I have found an erro when trying to create a damage system. In the video, the house doesn’t take damage when a single part of the model is anchored, which is really strange. the moment i unachor that single part everything works. For reference everything is welded to the anchored part.
I need it to work while that part is anchored otherwise everything is just a pain
local EF = script.Parent.EF.Value
local greenzone = script.Parent.GreenZone
greenzone.Touched:Connect(function(hit)
print(hit.Name)
--If its a base/cant be picked up same with hats!
if hit.Name == "Base" or hit.Name == "Baseplate" or hit.Parent.ClassName == "Accessory"or hit:FindFirstChild("IsTornadoPart") or hit.Parent:FindFirstChild("Humanoid") then return
else
hit:BreakJoints()
hit.Anchored = false
print("did the thing")
coroutine.resume(coroutine.create(function()
for i = 1,math.random(100,500) do
hit.Velocity=CFrame.new(hit.Position,greenzone.Position):vectorToWorldSpace(Vector3.new(500,50,0))
wait()
end
end))
end
end)
You may have to change tact here, or if an anchored part is required, then simulate force and momentum with classical equations yourself.
The documentation says:
The Anchored property determines whether the part will be immovable by physics. When enabled, a part will never change position due to gravity, other parts collisions, overlapping other parts, or any other physics-related causes.
And…
Finally, if an unanchored part is joined with an anchored part through an object like a weld, it too will act anchored.
Also, the center of mass stipulations states:
If the assembly has an anchored part, that part’s center of mass will be the assembly’s center of mass, and the assembly will have infinite mass
It’s quite hard to calculate physics yourself. If the part must truly be anchored, it will probably require simulation. You might have to calculate the rotation speed of the tornado, the angle of incidence of both colliding parts, adapt for local gravity and external affects, and fling the part with a best-guess impulse as a workaround?!?!
local greenzone = script.Parent.GreenZone
repeat
for i, part in pairs(greenzone:GetTouchingParts()) do
-- code here
end
task.wait(0.2)
until -- until tornado end