#Script not working.

1 messages · Page 1 of 1 (latest)

stable reef
#

local part = workspace.Smasher
local lastVelocity = Vector3.zero

part.Anchored = false
part.CanCollide = true

local objectDirection = part.CFrame.LookVector
part:ApplyImpulse(objectDirection * 250 * part:GetMass())

part:GetPropertyChangedSignal("AssemblyLinearVelocity"):Connect(function()
lastVelocity = part.AssemblyLinearVelocity
end)

part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
local speed = lastVelocity.Magnitude
print("Speed is", speed)
print("Velocity is", lastVelocity)
hum:TakeDamage(speed)
end
end)

stable reef
versed moat
#

by that, I mean you could take it's new position and subtract the old position from that

#

let me give you an example

#
local RunService = game:GetService("RunService")
local Part = Workspace[part directory]

local OldPosition = part.Position -- Will be constantly changed

local Connection = RunService.Heartbeat:Connect(function()
    local velocity = (part.Position - OldPosition).Unit -- Basically measures the distance between these two points
    print(velocity)

    OldPosition = part.Position -- Now we update the old position again
end)
versed moat
stable reef
#

oh ok thanks, it works now