Hello I’m making a projectile and I need to calculate the mass of the projectile so it doesn’t go on the ground!
Example i wanna do something like this
print(part.Mass)
Output: 100
the script was a dummy script
Hello I’m making a projectile and I need to calculate the mass of the projectile so it doesn’t go on the ground!
Example i wanna do something like this
print(part.Mass)
Output: 100
the script was a dummy script
Also, I’m not calculating it in a script, I’m doing it on command bar.
Could you not just loop through and add together the masses of all the objects inside the projectile?
Is this an assembly (eg. held together by welds or some other constraint)?
This might be useful to you:
https://developer.roblox.com/en-us/api-reference/property/BasePart/AssemblyMass
Yes, its held by welds
– Filling in max –
Also how would i make my hammer constantly spinning in one place. Because if you use CFrame.fromEulerAngles() it will spin around the map. I want it to spin in one place.
This is the source code so it wont be confusing.
local Tool = script.Parent.Parent
local SoundFolder = Tool.Sounds
local ThrewKnife = false
local VectorForce = Tool.VectorForce
local AnimationFolder = Tool.Animations
local RemoteFired = false
local WeldingModule = require(game:GetService("ServerScriptService").WeldingModule)
Tool.Remotes.ThrowShield.OnServerEvent:Connect(
function(player, position)
if ThrewKnife == true then
return
end
ThrewKnife = true
local char = player.Character
local humanoid = char.Humanoid
loadAnim = humanoid:LoadAnimation(AnimationFolder:WaitForChild("Throw"))
loadAnim:Play()
wait(0.50)
local projectile = game.ReplicatedStorage.Projectiles.MjolnirProjectile:Clone()
task.wait()
VectorForce.Force = Vector3.new(0, workspace.Gravity * projectile.AssemblyMass, 5)
VectorForce.Attachment0 = projectile.Attachment
projectile:PivotTo(CFrame.lookAt(Tool.Handle.Position, position))
projectile.PivotOffset = game.ReplicatedStorage.Projectiles.CAProjectile.PivotOffset
projectile.Parent = workspace:WaitForChild("Projectiles")
local direction = position - projectile.Position
projectile:ApplyImpulse(direction.Unit * projectile.Mass * 200)
Tool.Handle.Transparency = 1
for i,v in pairs(Tool.Handle:GetDescendants()) do
if v:IsA("MeshPart") then
v.Transparency = 1
end
end
task.wait(1)
Tool.AlignPosition.Attachment0 = projectile.Attachment
task.wait(0.5)
Tool.Remotes.ReturnShield:FireClient(player)
SoundFolder:WaitForChild("Return"):Play()
Tool.Handle.Transparency = 0
for i,v in pairs(Tool.Handle:GetDescendants()) do
if v:IsA("MeshPart") then
v.Transparency = 0
end
end
local knockback = Instance.new("BodyVelocity")
knockback.Parent = player.Character.HumanoidRootPart
knockback.P = 0
knockback.MaxForce = Vector3.new(math.huge, 0, math.huge)
knockback.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * -25
game:GetService("Debris"):AddItem(knockback, 0.1)
game:GetService("Debris"):AddItem(projectile, 0)
wait(1)
ThrewKnife = false
end
)
Don’t mind the code i used lua beautifier because im goofy
Where are you attempting to rotate it?
It will just constantly spin in the place your projectile is going.
I’m not sure I understand sorry, what lines are currently causing this behaviour?
no no no, I meant I would like it to spin constantly wherever your projectile is going. Like thors hammer, It sometimes spins when thrown
Ohhh I get what you mean, try either using :ApplyAngularImpulse, or try a torque:
https://developer.roblox.com/en-us/api-reference/class/Torque
I’ll go try that; I’ll message you if anything goes wrong