#I wanted to create a tool with a ball that moves, and if it goes out, you die. But how? I've already

1 messages · Page 1 of 1 (latest)

slate topaz
#

script

local Tool = script.Parent
local Ball = Tool:WaitForChild("Ball")

Ball.Parent = workspace

Ball.Anchored = false
Ball.CanCollide = true
Ball.CanTouch = false
Ball.CanQuery = false
Ball.Massless = false

task.delay(0.05, function()
Ball.CFrame = Ball.CFrame + Vector3.new(0, 3, 0)
Ball.AssemblyLinearVelocity = Vector3.new(0, 0, 0)

 Ball:ApplyImpulse(Vector3.new(
      math.random(-40, 40),
      30,
      math.random(-40, 40)
      ))

end)

local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
if Ball.AssemblyLinearVelocity.Magnitude < 0.1 then
Ball:ApplyImpulse(Vector3.new(
math.random(-20,20),
10,
math.random(-20,20)
))
end
end)