I’m basically trying to make a E to shoot basketball game, But I’m encountering this problem where the ball basically just goes under the ground when u click E. And the other problem is that the remote wont fire again once you’ve clicked E (Fires one time)
Client script :
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local work = game:GetService("Workspace")
local ClientReq = ReplicatedStorage:WaitForChild("ClientReq")
local u1 = game:GetService("Workspace"):FindFirstChild("Basketball"):FindFirstChild("Handle")
local player = game:GetService("Players").LocalPlayer
local dir = Vector3.new(u1.Position.X, u1.Position.Y, u1.Position.Z)
local boolean = true
UserInputService.InputBegan:Connect(function(Input, gpe)
if Input.KeyCode == Enum.KeyCode.E and player.Character:FindFirstChild("Basketball") then
for i,v in pairs(player.Character:FindFirstChild("Basketball"):GetDescendants()) do
if v.Name == "Handle" then
local b4 = v
ClientReq:FireServer(dir, b4, Input)
end
end
end
end)
UserInputService.InputEnded:Connect(function(Input, gpe)
if Input.KeyCode == Enum.KeyCode.E then
print("Hello worl.d")
end
end)
server script :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local ClientReq = ReplicatedStorage:WaitForChild("ClientReq")
local shootball = false
ClientReq.OnServerEvent:Connect(function(player, dir, b4, Input)
print(player)
print(dir)
print(b4)
--b4.Position = dir
local mag = (b4.Position - player.Character.HumanoidRootPart.Position).Magnitude
local unit = (b4.Position - player.Character.HumanoidRootPart.Position).Unit
if shootball == false then
b4.Velocity = (unit * mag) + Vector3.new(10, 110, 10)
b4.Parent = workspace
shootball = true
end
shootball = false
end)