Hello, I would like to know how to fix my code to create a replica of my baseball ball and throw it (I need only the replicas to be thrown) how can I correct my code and do that?
– server script ball
local tool = script.Parent
tool.RemoteEvent.OnServerEvent:Connect(function(player, event)
local mouse = player:GetMouse()
local Handle = tool.Handle
tool.Parent = workspace
Handle.CFrame = CFrame.new(Handle.Position, event)
local bv = Instance.new("BodyVelocity",Handle)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = tool.Handle.CFrame.LookVector * 70 -- Change the number if you want :D
local vel = tool.Handle.CFrame.LookVector
wait(.1)
tool.Handle.BodyVelocity:Destroy()
--- Adding the next part will result when they touch it then will like teleport to the position of the ball and like "take" it
Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
-- tool check
local tnot = script.Parent.Parent.Bat
local hastool = false
local tool = script.Parent.Parent.Ball
if player.Character:FindFirstChild(tool.Name) or player.Backpack:FindFirstChild(tool.Name) then
hastool = true
Handle.Anchored = false
wait(.1)
Handle.Anchored = true
Handle.Anchored = false
hastool = false
elseif player.Character:FindFirstChild(tnot.Name) or player.Backpack:FindFirstChild(tnot.Name) then
print("You already have the ball, you can't have the bat too.")
end -- end
end
end)
end)
script.Parent.Equipped:Connect(function()
for i = 0, -4, -.5 do
script.Parent.GripPos = Vector3.new(0,i,0)
wait()
end
for i = -4,0,.5 do
script.Parent.GripPos = Vector3.new(0,i,0)
wait()
end
end)