Basically, I’m trying to create a hockey stick with the function of picking up a puck and then shooting it. But there’s a few problems that I’ve encountered that i can’t seem to get around. First off, it requires me to double click when trying to shoot the puck which is probably the least of my concerns compared to the other two bugs. One being that whenever you do soot the puck it’ll travel some distance but then abruptly stop, only to continue moving forward when the player who shot it does (it also teleports the puck back to the original position when you unequip the stick). The second one being when you attempt to take the puck from another user it welds both of the users together and you can’t move.
-- (server script)
local tool = script.Parent
local puck = game.Workspace.TempPuck
local Holder = tool.Holder
local debounce = false
local Plr = game.Players.LocalPlayer
local E;
tool.Equipped:Connect(function()
E = Holder.Touched:Connect(function(other)
if other.Name == "TempPuck" then
if not debounce then
debounce = true
other:SetNetworkOwner(Plr)
local weld = Instance.new("Weld")
weld.Part0 = Holder.inv
weld.Part1 = puck
weld.Parent = Holder
wait(2)
debounce = false
end
end
end)
end)
tool.Unequipped:Connect(function()
for _, Child : Instance in pairs(Holder:GetChildren()) do
if Child:IsA("Weld") then
Child:Destroy()
end
end
E = E:Disconnect()
end)
-- (local script)
local tool = script.Parent
local puck = game.Workspace.TempPuck
local Holder = tool.Holder
local debounce = false
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
tool.Activated:Connect(function()
local Weld = Holder:FindFirstChildWhichIsA("Weld")
if not Weld then return end
local HRP = tool.Parent:WaitForChild("HumanoidRootPart")
local f = CFrame.new(HRP.CFrame.Position, Mouse.Hit.p)
--Weld.Part1.Position += (Vector3.new(f.LookVector.Unit.X,0,f.LookVector.Unit.Z))
local BF = Instance.new("BodyForce")
local v = f.LookVector.Unit * 175 --// Speed
BF.Force = Vector3.new(v.X,0,v.Z)
BF.Parent = Weld.Part1
for _, Child : Instance in pairs(Holder:GetChildren()) do
if Child:IsA("Weld") then
Child:Destroy()
end
end
wait()
BF:Destroy()
end)
I’d also like to mention I am not the best scripter but I would very much appreciate any help I can receive with this.