Im making my game BUT the bodyVelocity dosent move the ball. Here is the code
if player.GloveValues.SoulSnatcher.Value then
local SoulSnatcher = game.ServerStorage:WaitForChild("SoulServStorage"):WaitForChild("SoulSnatcher")
local char = player.Character
local newSoulSnatcher = SoulSnatcher:Clone()
local targetPosition = char.HumanoidRootPart.Position + Vector3.new(0, 5, 0)
newSoulSnatcher.Position = targetPosition
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(5000, 5000, 5000)
local direction = (cframe.p - newSoulSnatcher.Position).Unit
bodyVelocity.Velocity = direction * 500
bodyVelocity.Parent = newSoulSnatcher
newSoulSnatcher.Parent = workspace
local bodyPosition = Instance.new("BodyPosition", newSoulSnatcher)
bodyPosition.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyPosition.D = 10
bodyPosition.Position = targetPosition
local touchConn
touchConn = newSoulSnatcher.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
char.Humanoid.Sit = true
local force = Instance.new("BodyVelocity", char)
force.MaxForce = Vector3.new(2, 2, 2) * math.huge
force.Velocity = direction * 20
local rotation = Instance.new("BodyAngularVelocity", newSoulSnatcher)
rotation.AngularVelocity = Vector3.new(1, 1, 1) * math.pi * math.random(1, 5)
rotation.MaxTorque = Vector3.new(2, 2, 2) * math.huge
rotation.P = 5000
game:GetService("Debris"):AddItem(force, 0.35)
game:GetService("Debris"):AddItem(rotation, 0.35)
local Ragdoll = require(game:GetService("ReplicatedStorage"):WaitForChild("RagdollCharacterV1"))
local RiggedChar
local Ragdolled = false
if not RiggedChar then
RiggedChar = Ragdoll:SetupRagdoll(char, true)
end
if not Ragdolled then
RiggedChar.Ragdoll(4)
wait(4)
RiggedChar.Unragdoll()
end
char.Humanoid.Sit = false
end
end
end)
wait(5)
if touchConn ~= nil then touchConn:Disconnect() end
newSoulSnatcher:Destroy()
end
If u can help ty!! If someone is asking CFrame is the mouse.Hit (This is made by remoteevent)
BodyVelocities, BodtAngularVelocities and BodyPositions are deprecated (but should work so don’t worry). Just in case, you can try using LineForce and AngularVelocity, those aren’t deprecated.
Mouse.hit got replaced with UserInputService:GetMouseLocation() and workspace:Raycast(). but I’m sure Mouse.hit still works so also don’t worry. (basically roblox wants you to manually raycast)
You can add more MaxForce to the BodyVelocity (way more) if it doesn’t work (it should with 5k idk why it doesnt work) or maybe it’s because you didnt change ‘Velocity’ property. < I’m sure this is the solution
local Ragdoll = require(game:GetService("ReplicatedStorage").RagdollCharacterV1)
local event = game:GetService("ReplicatedStorage"):WaitForChild("AbiliyEvent")
event.OnServerEvent:Connect(function(player:Player, equipped,cframe)
local char = player.Character
local Hum = char:FindFirstChildOfClass("Humanoid")
if equipped.Value == 1 then
local Fart = game.ServerStorage:WaitForChild("Fart")
local ClonedFart = Fart:Clone()
ClonedFart.Parent = char.HumanoidRootPart
ClonedFart:Play()
Hum.WalkSpeed = 32
wait(2.5)
ClonedFart:Destroy()
Hum.WalkSpeed = 16
elseif equipped.Value == 3 then
if player.GloveValues.SoulSnatcher.Value then
local SoulSnatcher = game.ServerStorage:WaitForChild("SoulServStorage"):WaitForChild("SoulSnatcher")
local char = player.Character
local newSoulSnatcher = SoulSnatcher:Clone()
local targetPosition = char.HumanoidRootPart.Position + Vector3.new(0, 5, 0)
newSoulSnatcher.Position = targetPosition
local bodyVelocity = Instance.new("LineForce")
bodyVelocity.MaxForce = 15000
local direction = (cframe.p - newSoulSnatcher.Position).Unit
bodyVelocity.Magnitude = tonumber(direction * 500)
bodyVelocity.Parent = newSoulSnatcher
newSoulSnatcher.Parent = workspace
local bodyPosition = Instance.new("BodyPosition", newSoulSnatcher)
bodyPosition.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyPosition.D = 10
bodyPosition.Position = targetPosition
local touchConn
touchConn = newSoulSnatcher.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
char.Humanoid.Sit = true
local force = Instance.new("BodyVelocity", char)
force.MaxForce = Vector3.new(2, 2, 2) * math.huge
force.Velocity = direction * 20 -- Push the player away from the SoulSnatcher
local rotation = Instance.new("BodyAngularVelocity", newSoulSnatcher)
rotation.AngularVelocity = Vector3.new(1, 1, 1) * math.pi * math.random(1, 5)
rotation.MaxTorque = Vector3.new(2, 2, 2) * math.huge
rotation.P = 5000
game:GetService("Debris"):AddItem(force, 0.35)
game:GetService("Debris"):AddItem(rotation, 0.35)
local Ragdoll = require(game:GetService("ReplicatedStorage"):WaitForChild("RagdollCharacterV1"))
local RiggedChar
local Ragdolled = false
if not RiggedChar then
RiggedChar = Ragdoll:SetupRagdoll(char, true)
end
if not Ragdolled then
RiggedChar.Ragdoll(4)
wait(4)
RiggedChar.Unragdoll()
end
char.Humanoid.Sit = false
end
end
end)
wait(5)
if touchConn ~= nil then touchConn:Disconnect() end
newSoulSnatcher:Destroy()
end
end
end)
I forgot to say it, but the point 1 and 2 is just in case roblox stops supporting those classes, you shouldn’t worry about them now, and I don’t have any idea of what the problem may be.
Also, I think VectorForce is better for replicating BodyVelocity and LineForce for replicating BodyPosition… (Didn’t think about that.) Also, VectorForce needs an attachment (and lineforce two bc it moves an attachment to another). You can’t even use tonumber on Vector3, so maybe that’s also another error.
Don’t do tonumber(direction * 500). That code tries to convert a Vector3 into a number and fails. That’s why I suggested using VectorForce and setting ‘RelativeTo’ to World. (it’s an enum)
You don’t need to set .Position to direction+Vector3.new(200,0,0) (you can set it to Vector3.zero, just change .RelativeTo because the direction is relative to the world.