So i have a racket that is supposed to spawn a ball and then after a bit the ball loses velocity,
But for some reason the ball flys up and then loses velocity! The script is in serverscriptservice, and is a server script.
Ignore the –
local storage = game.ReplicatedStorage
local RacketEvent = storage.RacketEvents.RacketClient
local function onActivation(player)
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
local ogball = game.ReplicatedStorage:WaitForChild("ball")
local ball = ogball:Clone()
--ball.Shape = Enum.PartType.Ball
--ball.Color = Color3.new(1, 0.333333, 0)
--ball.Size = Vector3.new(2,2,2)
--ball.Material = Enum.Material.Granite
--ball.CanCollide = true
wait(.1)
ball.Parent = root
local newCFrame = root.CFrame * CFrame.new(Vector3.new(0,-2,0))
local cf = ball.CFrame
ball.CFrame = newCFrame
--local Velocity = Instance.new("BodyVelocity")
--Velocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
ball.Velocity = ball.CFrame.lookVector * 90
ball.Parent = game.Workspace
local speed = Vector3.new(90,90,90)
wait(.5)
for count = 1, 10 do
wait(.1)
ball.Velocity = speed - Vector3.new(10,10,10)
print('this is working')
end
wait(1)
--Velocity.Parent = ball
ball.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
ball.CanCollide = false
ball.CanTouch = false
ball.Transparency = 1
--sound:Play()
end
end)
-- ball.Touched:connect(function(hit)
-- if hit:IsA("Part") and hit.Parent ~= player.Character and hit.Parent ~= player.Character.Racket then
-- ball.CanCollide = false
-- ball.CanTouch = false
-- ball.Transparency = 1
--sound:Play()
end
--end)
--end
RacketEvent.OnServerEvent:Connect(onActivation)
The speed variable doesn’t change at all, so that statement evaluates to ball.Velocity = Vector3.new(80,80,80) and the script keeps the velocity at that
Perhaps you meant to do:
for count = 1, 10 do
wait(.1)
speed -= Vector3.new(10,10,10)
ball.Velocity = speed
print('this is working')
end
In addition to that, you should definitely not be using the .Velocity property itself, and instead switch to .AssemblyLinearVelocity
Alright so changing the velocity stops it from going very high up and what not but it still doesnt go in the direction of the torso. Just in that same direction /: