Teir199
(TEIRMADNESS)
November 22, 2025, 9:55pm
1
so im trying to make it so that the block will throw but bodyvelocity wont remove
local RS = game:GetService("ReplicatedStorage")
local greenblock = RS:WaitForChild("FlyingBlock")
local throwevent = RS:WaitForChild("ThrownBlock")
throwevent.OnServerEvent:Connect(function(player: Player ,holdingblockpos, newblock, mouseHit)
newblock = greenblock
newblock:Clone()
newblock.Parent = workspace
newblock.Position = holdingblockpos.Position
local force = 35
local BodyVelocity = Instance.new('BodyVelocity', newblock)
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity.Velocity = (mouseHit - holdingblockpos.Position).Unit * force + Vector3.new(0,(force / 2),0)
BodyVelocity.P = 500
task.wait(0.1)
BodyVelocity:Remove()
end)
TEIRMADNESS:
BodyVelocity:Remove()
Remove is deprecated , you should use :Destroy() instead, and you can also use debris service for removing instances at a scheduled time, like this
local debris = game:GetService("Debris"):
debris:AddItem(instance,secondsUntilRemove)
you can see debris service docs here
2 Likes
ig1oo1
(hello)
November 23, 2025, 12:01am
3
BodyVelocity is also deprecated. You should instead use LinearVelocity or VectorForce.
You need to set newblock to greenblock:Clone()
You should not set the parent of an instance using the second parameter of Instance.new()
Here is the updated code.
local RS = game:GetService("ReplicatedStorage")
local greenblock = RS:WaitForChild("FlyingBlock")
local throwevent = RS:WaitForChild("ThrownBlock")
throwevent.OnServerEvent:Connect(function(player: Player ,holdingblockpos, newblock, mouseHit)
newblock = greenblock:Clone()
newblock.Parent = workspace
newblock.Position = holdingblockpos.Position
local attachment = Instance.new("Attachment")
attachment.Parent = newblock
attachment.CFrame = CFrame.new(0,0,0)
local force = 35
local LinearVelocity = Instance.new('LinearVelocity')
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = (mouseHit - holdingblockpos.Position).Unit * force + Vector3.new(0,(force / 2),0)
LinearVelocity.Attachment0 = attachment
LinearVelocity.Parent = newblock
task.delay(0.1, function()
LinearVelocity:Destroy()
end)
-- or use debris
-- game.Debris:AddItem(LinearVelocity, 0.1)
end)
jellolemo
(jellolemo)
November 23, 2025, 1:27am
4
Please don’t do game.Service and please don’t use DebrisService as a whole (bc it has a part limit), instead do this;
task.delay(5, function()
part:Destroy()
end)
2 Likes
DataSigh
(DataSigh)
November 23, 2025, 2:03am
6
This also has a potential drawback in that the scheduled callback will never run if the script is disabled or destroyed before the callback runs. Whereas DebrisService runs outside the context of the script, guaranteeing the instance will eventually be destroyed even if the script is disabled or destroyed. For the posters specific problem, DebrisService is the best option
1 Like
Teir199
(TEIRMADNESS)
November 23, 2025, 2:59am
7
it does work and doesnt float now, but it just drops and doesnt throw with force
1kaelen1
(IMoggedOOP)
November 23, 2025, 3:01am
8
BodyVelocity is fine to use, unlike Remove which parents the instance and all children to nil. I’m sure you see how that’s a bad thing
1 Like
ig1oo1
(hello)
November 23, 2025, 4:20am
9
Yeah, but it still is unpreferable. You shouldn’t use it if you don’t have to.
1kaelen1
(IMoggedOOP)
November 23, 2025, 4:23am
10
well BodyVelocity is like 5 times easier to use than LinearVelocity so…
ig1oo1
(hello)
November 23, 2025, 4:24am
11
You just need an attachment for LinearVelocity… it’s not that much harder.
1 Like
You could try increasing your force, increasing the time before destroying the body velocity or try a mix
Teir199
(TEIRMADNESS)
November 24, 2025, 12:25am
13
this is what i have rn:
local RS = game:GetService("ReplicatedStorage")
local greenblock = RS:WaitForChild("FlyingBlock")
local throwevent = RS:WaitForChild("ThrownBlock")
throwevent.OnServerEvent:Connect(function(player: Player ,holdingblockpos, newblock, mouseHit)
newblock = greenblock:Clone()
newblock.Parent = workspace
newblock.Position = holdingblockpos.Position
local attachment = Instance.new("Attachment")
attachment.Parent = newblock
attachment.CFrame = CFrame.new(0,0,0)
local force = 1000
local LinearVelocity = Instance.new('LinearVelocity')
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = Vector3.new((mouseHit - holdingblockpos.Position).Unit * force + Vector3.new(0,(force / 2),0))
LinearVelocity.Attachment0 = attachment
LinearVelocity.Parent = newblock
task.delay(0.1, function()
LinearVelocity:Destroy()
end)
end)
--(mouseHit - holdingblockpos.Position).Unit * force + Vector3.new(0,(force / 2),0)
but it says:
ServerScriptService.BlockManager:21: attempt to perform arithmetic (sub) on nil and Vector3 - Server - BlockManager:21
Teir199
(TEIRMADNESS)
November 24, 2025, 1:49am
14
i did it
local force = 50
local BodyVelocity = Instance.new("BodyVelocity", newblock)
BodyVelocity.MaxForce = Vector3.new(1, 1, 1) * 10000000;
BodyVelocity.Velocity = newblock.CFrame.UpVector * force;
debris:AddItem(BodyVelocity, 0.1)
thanks for anyone who helped!
1 Like
system
(system)
Closed
December 8, 2025, 1:50am
15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.