Hey. I want to make a grapple that takes you to wherever your mouse is when you press F but for some reason the script tells me that it has a Vector3 on a line instead of an Object when there is an Object: Workspace.bruceywayne.NEW:38: bad argument #2 to 'new' (Object expected, got Vector3)
This is the script:
player = game.Players.LocalPlayer
mouse = player:GetMouse()
target = mouse.Hit.p
activated = true
local character = game.Players.LocalPlayer.Character
Humanoid = character.Humanoid
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=01231272033"
local animation2 = Instance.new("Animation")
animation2.AnimationId = "http://www.roblox.com/Asset?ID=01231293787"
local animTrack = Humanoid:LoadAnimation(animation)
local animTrack2 = Humanoid:LoadAnimation(animation2)
local GrappleSound = Instance.new("Sound", workspace)
GrappleSound.SoundId = "http://www.roblox.com/Asset?ID=996815728"
GrappleSound.Volume = 1
function onKeyPress(inputObject, gameProcessedEvent)
for i, v in pairs(game.Players:GetChildren()) do
if (v.Character.UpperTorso.Position - mouse.Hit.p).magnitude <= 100 then
if inputObject.KeyCode == Enum.KeyCode.F and activated == true then
local Grapple = game.Players.LocalPlayer.Character.rhand
if character and character:findFirstChild("Humanoid") then
Grapple.Union.Transparency = 0
activated = false
animTrack:Play()
GrappleSound:Play()
local partA = Grapple.PartA
local attachmentA = Instance.new("Attachment", partA)
attachmentA.Position = Vector3.new(0, 0, -1)
local partB = mouse.Hit.p
local attachmentB = Instance.new("Attachment", partB)
attachmentB.Position = Vector3.new(0, .5, 0)
local Rope = Humanoid.Parent.rhand.Beam
Rope.Attachment0 = attachmentA
Rope.Attachment1 = attachmentB
Rope.Segments = 1
Rope.Width0 = 0.3
Rope.Width1 = 0.3
wait(1)
animTrack:Stop()
animTrack2:Play()
local b = Instance.new("BodyPosition")
b.position = mouse.Hit.p
b.maxForce = Vector3.new(500000000, 500000000, 500000000)
b.Parent = character.UpperTorso
wait(1.5)
Rope.Attachment0 = nil
attachmentA:Destroy()
Rope.Attachment1 = nil
attachmentB:Destroy()
b.Parent = nil
activated = true
animTrack2:Stop()
Grapple.Union.Transparency = 1
end
end
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

3 comments
You're parenting 'attachmentB' to 'partB', that's assigned to mouse.Hit.p which is a Vector3
So what should I do to fix it?
could create a part at the mouse's position, then create the attachment and parent it there