This script for me inside of my tool only worked local and cloned the part for the client. I want to be able to make this script clone the part and shoot in the mouse’s direction on a server script, although I dont know how I would fit something like that in my script.
Here is my code
local tool = script.Parent.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local GamePuck = script.Parent
local bodyForce = Instance.new('BodyForce', GamePuck)
game:GetService("UserInputService").InputBegan:Connect(function(input)
if(input.UserInputType == Enum.UserInputType.MouseButton1)then
wait(0.08)
game.Workspace.GamePuck:Destroy()
if script.Parent.WeldPuck.Disabled then
local GamePuck = game.ReplicatedStorage.GamePuck:Clone()
GamePuck.Parent = workspace
local antiGravity = Instance.new("BodyForce")
antiGravity.Force = Vector3.new(0, workspace.Gravity * GamePuck:GetMass(), 0)
antiGravity.Parent = GamePuck
workspace.GamePuck.CFrame = script.Parent.Parent.PuckAttract.CFrame
GamePuck.Script.Disabled = true
GamePuck.CFrame = CFrame.Angles(0,180,90)
GamePuck.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(-3,-2.5,-2)
GamePuck.CFrame = CFrame.new(GamePuck.Position, mouse.Hit.p)
GamePuck.Transparency = 0
GamePuck.Velocity = CFrame.new(plr.Character.HumanoidRootPart.Position, mouse.Hit.p).lookVector * 130
local VerifyPuck = script.Parent.Parent.PuckAttract.VerifyPuck
if script.Parent.Parent.PuckAttract.VerifyPuck then
VerifyPuck:Destroy()
end
task.spawn(function()
script.Disabled = true
if script.Parent.WeldPuck.Disabled then
wait(0.2)
script.Parent.WeldPuck.Enabled = true
end
task.spawn(function()
wait(0.08)
antiGravity.Name = 'antiGravity'
antiGravity.Force = Vector3.new(GamePuck:GetMass() * workspace.Gravity == 1, 0)
end)
wait(0.2)
GamePuck.Touched:connect(function(hit)
antiGravity.Name = 'antiGravity'
antiGravity.Force = Vector3.new(GamePuck:GetMass() * workspace.Gravity == 196.2, 0)
end)
end)
end
end
end)