My goal here is to unanchor the part and throw it away when the script’s parent touches it. When it’s unanchored, everything in the script works perfectly fine. But when the parts are anchored, they don’t work.
-- Define the tornado's properties
local tornado = script.Parent
local tornadoForce = 10
local tornadoRadius = 10
-- Function to apply tornado force to objects
local function applyTornadoForce(object)
object.Anchored = false
local direction = (object.Position - tornado.Position).unit
local distance = (object.Position - tornado.Position).magnitude
local force = tornadoForce * (1 - distance / tornadoRadius)
local velocity = direction * force
local angularVelocity = Vector3.new(math.random(-10, 10), math.random(-10, 10), math.random(-10, 10))
-- Add a 1/5 chance of unanchoring and flinging the object
if math.random(1,5) == 1 then
object.Anchored = false
local throwForce = math.random(200, 500)
local throwDirection = (object.Position - tornado.Position).unit
object.Velocity = object.Velocity + throwDirection * throwForce
object.Velocity = object.Velocity + velocity
end
end
local function onTouch(part)
part.Anchored = false
applyTornadoForce(part)
end
script.Parent.Touched:Connect(onTouch)
I’ve tried making the chance to be 100%, issue persists.
Not sure what else to do.