The ball would work as intended when you’re close enough but it just puts you in place when you’re at a far distance from your target.
The video below will show you how it should work and the error:
Here’s the server script:
(Disclaimer, it is not the full script but a portion of what you should need to know)
local ball = rs.Ball:Clone()
local character = plr.Character
local sounds = character.Sounds
ball.Touched:Connect(function(h)
if h.Parent and h.Parent.Name ~= plr.Name then
local echaracter = h.Parent
if echaracter and echaracter:IsA("Model") and echaracter:FindFirstChild("Humanoid") then
local targetHumanoid = echaracter:FindFirstChild("Humanoid")
local targetTorso = echaracter:FindFirstChild("HumanoidRootPart")
local plrHumanoid = character:FindFirstChild("Humanoid")
local plrTorso = character:FindFirstChild("HumanoidRootPart")
local erd = echaracter.Values:FindFirstChild("IsRagdoll")
local rd = character.Values:FindFirstChild("IsRagdoll")
local esounds = echaracter.Sounds
if targetTorso then
erd.Value = true
targetHumanoid.WalkSpeed = 0
ball.explode_1:Play()
esounds.scream:Play()
disableBall(ball)
local velocity = dir * 750
echaracter.HumanoidRootPart.Velocity = velocity
wait(2)
erd.Value = false
targetHumanoid.WalkSpeed = 25
end
end
end
end)
Have you tried this in a real game and not against NPCs? This could just be a NetworkOwnership problem. I’m assuming this script is also a server-script and not a LocalScript but correct me if I’m wrong.
I set the NetworkOwnership to the server before setting velocity.
Code:
local Players = game:GetService("Players")
local ball = rs.Ball:Clone()
local character = plr.Character
local sounds = character.Sounds
ball.Touched:Connect(function(h)
if h.Parent.Name == plr.Name then
continue
end
local echaracter = h.Parent
local ePlayer = Players:GetPlayerFromCharacter(echaracter)
if ePlayer and echaracter:FindFirstChild("Humanoid") then
local targetHumanoid = echaracter.Humanoid
local targetTorso = echaracter:FindFirstChild("HumanoidRootPart")
local erd = echaracter.Values:FindFirstChild("IsRagdoll")
local esounds = echaracter.Sounds
if targetTorso then
erd.Value = true
targetHumanoid.WalkSpeed = 0
ball.explode_1:Play()
esounds.scream:Play()
disableBall(ball)
local velocity = dir * 750
echaracter:SetNetworkOwner(nil)
echaracter.HumanoidRootPart.Velocity = velocity
task.wait(2)
echaracter.HumanoidRootPart:SetNetworkOwner(ePlayer)
erd.Value = false
targetHumanoid.WalkSpeed = 25
end
end
end)