Hi, I want to make a spring attachment from the players position to wherever the mouse is. It keeps giving me this error:
invalid argument #3 (Instance expected, got number)
Can anyone help? This is my current script:
--// Local script inside StarterGUI (irrelevant but here if anyone asks) \\
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Move:Connect(function()
local target = mouse.Target
if not target then
mouse.Icon = 'http://www.roblox.com/asset/?id=591711615'
else
if target:IsA("BasePart") or target:IsA("Model") then
if target == workspace.Base or target == workspace.Base2 or target.Parent == workspace.Map then
if target.Parent == workspace then
mouse.Icon = 'http://www.roblox.com/asset/?id=6888146193'
if mouse.Icon == 'http://www.roblox.com/asset/?id=6888146193' then
mouse.Button1Down:Connect(function()
game.ReplicatedStorage.CreatePart:FireServer(target, mouse.Hit)
end)
end
else
mouse.Icon = 'http://www.roblox.com/asset/?id=6888146193'
if mouse.Icon == 'http://www.roblox.com/asset/?id=6888146193' then
mouse.Button1Down:Connect(function()
game.ReplicatedStorage.CreatePart:FireServer(target, mouse.Hit)
end)
end
end
else
mouse.Icon = 'http://www.roblox.com/asset/?id=591711615'
end
end
end
end)
--// Server Script inside ServerScriptService (where the error is) \\
local ropeismade = false
local Rope = Instance.new("SpringConstraint")
game.ReplicatedStorage.CreatePart.OnServerEvent:Connect(function(player, part, mousepos)
if ropeismade == true then
return
elseif ropeismade == false then
local A0 = Instance.new('Attachment')
local A1 = Instance.new('Attachment')
ropeismade = true
A0.Parent = mousepos --Error on this line
A1.Parent = player.Character.HumanoidRootPart
Rope.Attachment0 = A0
Rope.Attachment1 = A1
Rope.Parent = player.Character
Rope.Visible = true
Rope.LimitsEnabled = true
Rope.Coils = 0
Rope.Thickness = 0.1
Rope.Color = BrickColor.new("Institutional white")
Rope.MaxLength = (player.Character.HumanoidRootPart.Position - part.Position).Magnitude
local BV = Instance.new('BodyVelocity')
local char = player.Character
char:WaitForChild("Humanoid"):GetPropertyChangedSignal("MoveDirection"):Connect(function()
BV.Velocity = player.Character.Humanoid.MoveDirection * 25
BV.MaxForce = Vector3.new(1000000,0,1000000)
end)
BV.Parent = char.HumanoidRootPart
end
end)