LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:10am
#1
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
sjr04
(uep)
December 31, 2020, 10:18am
#2
What is gorp
? It’s not a BasePart, so your script isn’t working
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:20am
#3
the gorp is the gun part.
like when the spring should be , from the gun part to the mouse.Hit
sjr04
(uep)
December 31, 2020, 10:21am
#4
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
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:23am
#5
i meant to parent the Attachment to a cframe value.
sjr04
(uep)
December 31, 2020, 10:24am
#6
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.
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:25am
#7
So how can i get the part from the CFrame? or there is another option instead of Mouse.Hit???
sjr04
(uep)
December 31, 2020, 10:25am
#8
You can use Mouse.Target
which gives you the part the mouse is hovering over.
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:29am
#9
Still Not working. its still giving error:
Attachments must be parented to a PartInstance.
sjr04
(uep)
December 31, 2020, 10:29am
#10
Then that means you are hovering over nothing, so Mouse.Target
is nil.
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:30am
#11
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)
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:41am
#13
Ty. But know im getting this error:
Expected Attachment got Part for SpringConstraint:Attachment0.
LOG1CEXE
(Kali_Linux)
December 31, 2020, 10:52am
#14
I got it working but i can’t see the Rope , my character is just walking weird
https://gyazo.com/9dc2df6dfa10a7b86f0c43189fcef427
dthecoolest
(dthecoolest)
December 31, 2020, 10:59am
#15
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.
LOG1CEXE
(Kali_Linux)
December 31, 2020, 11:01am
#16
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