Eror with making a Spring

Hello, I’m trying to make a spring between the mouse hit to the gun flare position.

The Error I’m getting: Attachments must be parented to a PartInstance.

Here is the code

Local Script:

script.Parent.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		game.ReplicatedStorage.sendMsg:FireServer(game.Players.LocalPlayer, Mouse.Hit)
	end)
end)

Script:

game.ReplicatedStorage.sendMsg.OnServerEvent:Connect(function(plr, mousepos)
	local gorp = plr.Character.taser.Flare
	
	local coil = Instance.new("SpringConstraint", gorp)
	
	local fAttach = Instance.new("Attachment", gorp)
	local sAttach = Instance.new("Attachment", mousepos)
	
	coil.Attachment0 = gorp
	coil.Attachment1 = mousepos
	
	
end)
1 Like

What is gorp? It’s not a BasePart, so your script isn’t working

the gorp is the gun part.
like when the spring should be , from the gun part to the mouse.Hit

Oh, I see this. mousepos is sent as Mouse.Hit, so you are trying to parent the Attachment to a CFrame value. Perhaps you meant gorp or another part

i meant to parent the Attachment to a cframe value.

That doesn’t work, instances can be parented to instances only. I am not sure what you meant to do. Attachments can’t be parented to non-parts.

So how can i get the part from the CFrame? or there is another option instead of Mouse.Hit???

You can use Mouse.Target which gives you the part the mouse is hovering over.

Still Not working. its still giving error:
Attachments must be parented to a PartInstance.

Then that means you are hovering over nothing, so Mouse.Target is nil.

Nope , I tried to print the target and it shows liamazu1000, my username, So how does i click my character if i click baseplate???

Here is the code:

game.ReplicatedStorage.sendMsg.OnServerEvent:Connect(function(plr, mousepos)
	local gorp = plr.Character.taser.Flare
	print(mousepos)
	local coil = Instance.new("SpringConstraint", gorp)
	
	local fAttach = Instance.new("Attachment", gorp)
	local sAttach = Instance.new("Attachment", mousepos)
	
	coil.Attachment0 = gorp
	coil.Attachment1 = mousepos
	
	
end)

When sending a remote to the server, you don’t include the player, just your arguments only.
game.ReplicatedStorage.sendMsg:FireServer(Mouse.Hit)

Ty. But know im getting this error:

Expected Attachment got Part for SpringConstraint:Attachment0.

I got it working but i can’t see the Rope , my character is just walking weird

https://gyazo.com/9dc2df6dfa10a7b86f0c43189fcef427

Gotta make the rope visible, through the book property in the documentation. Although the walking around weirdly seems to mean the rope constraint is working.

Oh, When i used instance.new() it made the rope invisible. Thank you
G’day!!!

Worried about that, it automatically sends the local player, so this

with your arguments should be