Ok so when a player equips a tool and clicks there parts are made invisible, they get welded to a new part, and they are suppose to fly around with the part. Thing is I don't know if I am missing or doing something wrong, might be something to do with the welding, or I may have to do userinputservice and when they press "w","s",A",d" then to direct a force in that direction. I would appreciate the help!
local tool = script.Parent
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local cam = game.Workspace:WaitForChild("Camera")
local emit = tool:WaitForChild("Emit")
tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
print("Hi")
local distance = ( player.Character.Torso.Position- Mouse.Hit.p).magnitude
if distance < 100 then
if game.Workspace:FindFirstChild("Ball") == nil then
local part = Instance.new("Part")
part.Name = "Ball"
part.Shape = "Ball"
part.Transparency = 1
part.CanCollide = false
part.Parent = game.Workspace
part.CFrame = player.Character.Torso.CFrame + Vector3.new(0,20,0)
wait("Good")
local clone = emit:Clone()
emit.Parent = game.Players.LocalPlayer.Character.Torso
print("Better")
local ball = game.Workspace:WaitForChild("Ball")
local weld = Instance.new("Weld")
weld.Parent = script.Parent
weld.Part0 = game.Workspace:WaitForChild("Ball")
weld.Part1 = game.Players.LocalPlayer.Character.Torso
game.Players.LocalPlayer.Character.Torso.Transparency = 1
game.Players.LocalPlayer.Character.Head.Transparency = 1
game.Players.LocalPlayer.Character.Head.face.Transparency = 1
game.Players.LocalPlayer.Character["Right Arm"].Transparency = 1
game.Players.LocalPlayer.Character["Left Arm"].Transparency = 1
game.Players.LocalPlayer.Character["Right Leg"].Transparency = 1
game.Players.LocalPlayer.Character["Left Leg"].Transparency = 1
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA("Hat") then v.Handle.Transparency = 1
end
end
game.Players.LocalPlayer.Character.Torso.CFrame = part.CFrame
print("Perfect")
cam.CameraSubject= game.Workspace:WaitForChild("Ball")
cam.CameraType = "Follow"
local force = Instance.new("BodyVelocity")
force.P = 23
force.MaxForce = Vector3.new(10000,10000,10000)
force.Velocity = Vector3.new(5,5,5)
force.Parent = part
end
end
end)
end)
tool.Unequipped:connect(function()
game.Workspace:FindFirstChild("Ball"):Remove()
game.Players.LocalPlayer.Character.Torso.Transparency = 0
game.Players.LocalPlayer.Character.Head.Transparency = 0
game.Players.LocalPlayer.Character.Head.face.Transparency = 0
game.Players.LocalPlayer.Character["Right Arm"].Transparency = 0
game.Players.LocalPlayer.Character["Left Arm"].Transparency = 0
game.Players.LocalPlayer.Character["Right Leg"].Transparency = 0
game.Players.LocalPlayer.Character["Left Leg"].Transparency = 0
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA("Hat") then v.Handle.Transparency = 0
end
end
game.Players.LocalPlayer.Character.Torso:FindFirstChild("Emit"):Remove()
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
end)

1 comment
Too much code to read -.-