Hello,
I’m making a goalkeeper tool for an anime football game.
i made a script for the catch and a script for the throw, but i dont know how to make the throw one. i want that when i press t and the ball is attached to the right arm, the ball will be throwed. in addition to this, i have another problem, that when i unequip the tool the ball will not be attacched, but when i equip it again, the ball auto attach itself to the right arm again and i don’t know how to solve it
here the tool
Catch script
bin = script.Parent
function Attach(Part)
local RA = script.Parent.Handle
local weld = Instance.new("Weld")
weld.Part0 = RA
weld.Part1 = Part
weld.C0 = CFrame.new(0,0,0)
weld.C1 = CFrame.new(1,0,1)
weld.Parent = RA
end
local Player = game.Players.LocalPlayer
Player.CharacterAdded:Wait()
local Character = Player.Character
local RL = Character:FindFirstChild("Right Arm")
local cooldown = 2
local debounce = false
local Anim = script.Parent.LowGrab
local hum = Character:WaitForChild("Humanoid")
function onKeyDown(key)
if key == "f" then
if not debounce then
debounce = true
local playAnim = hum:LoadAnimation(Anim)
playAnim:Play()
script.Parent.Handle.Touched:connect(function(hit)
if hit.Locked == true or hit.Anchored == true then return end
if hit.Name == "Ball" or hit.Name == "ball" then
script.Parent.Ball.Value = 1
local ball = hit
if (script.Parent.Handle.Position - ball.Position).magnitude then
Attach(ball)
wait(3)
script.Parent.Ball.Value = 0
end
end
wait(cooldown)
debounce = false
end)
end
end
end
bin.Unequipped:connect(function()
script.Parent.Handle.Attach.Disabled = true
end)
function onSelected(mouse)
mouse.KeyDown:connect(onKeyDown)
end
bin.Equipped:connect(onSelected)
Throw script
bin = script.Parent
local Player = game.Players.LocalPlayer
Player.CharacterAdded:Wait()
local Character = Player.Character
local cooldown = 2
local debounce = false
local Animm = script.Parent.Throw
local hum = Character:WaitForChild("Humanoid")
function onKeyDown(key)
if key == "t" then
if not debounce then
debounce = true
local playAnim = hum:LoadAnimation(Animm)
playAnim:Play()
wait(cooldown)
debounce = false
end
end
end
end
bin.Unequipped:connect(function()
end)
function onSelected(mouse)
mouse.KeyDown:connect(onKeyDown)
end
bin.Equipped:connect(onSelected)
Attach script inside the handle
function Attach(Part)
local brick = script.Parent
local weld = Instance.new("Weld")
weld.Part0 = brick
weld.Part1 = Part
local temp = CFrame.new((brick.Position - Part.Position) * 0.5)
weld.C0 = brick.CFrame:inverse() * temp
weld.C1 = Part.CFrame:inverse() * temp
weld.Parent = brick
end
function x(hit)
if hit.Name == "Ball" and script.Parent.Parent.Ball.Value == 0 then
script.Parent.Parent.Ball.Value = 1
Attach(hit)
end
end
Connection = script.Parent.Touched:connect(x)