Hello, so I am making a swinging game, and the rope comes out of the right hand, however when I did this, the player is not able to move anymore, and I have no idea why. Can anybody help? Here is my current code:
Pretty sure you cant move the character from places other than HumanoidRootPart, could be very wrong on that tho
Try parenting it to HumanoidRootPart but keep the attachment to the hand and see if it works
just remembered an open source project from a good while ago of something similar to this
hopefully it has some mechanics you can just rip out or learn from
here is a download to the game open-source-sekiro-grapple-hook.rbxl (76.7 KB)
local char = script.Parent
local player = game.Players.LocalPlayer
local Rope
function createRope(target, mousepos, isholdingdown)
if isholdingdown == false then
Rope:Destroy()
return
elseif (char.HumanoidRootPart.Position - mousepos).Magnitude > 1000 then
return
elseif isholdingdown == true then
local A0 = Instance.new('Attachment')
local A1 = Instance.new('Attachment')
A0.Parent = target
A0.WorldPosition = mousepos
A1.Parent = player.Character:WaitForChild("fakeHand")
Rope = Instance.new("SpringConstraint")
Rope.Attachment0 = A0
Rope.Attachment1 = A1
Rope.Parent = player.Character:WaitForChild("fakeHand")
Rope.Visible = true
Rope.LimitsEnabled = true
Rope.Coils = 0
Rope.Thickness = 0.1
Rope.Color = BrickColor.new("Institutional white")
Rope.MaxLength = (player.Character:WaitForChild("HumanoidRootPart").Position - target.Position).Magnitude
local VF = Instance.new("VectorForce");
VF.Name = "SpiderForce";
VF.Attachment0 = player.Character.PrimaryPart.RootRigAttachment;
VF.Parent = player.Character.PrimaryPart;
end
end
local fakeHand = game:GetService("ReplicatedStorage"):WaitForChild("fakeHand")
function MakeFakeHand()
local newHand = fakeHand:Clone()
newHand.Parent = player.Character
newHand.CFrame = player.Character:WaitForChild("RightHand").CFrame
local weld = Instance.new("WeldConstraint", newHand)
weld.Part0 = newHand
weld.Part1 = player.Character:WaitForChild("RightHand")
end
MakeFakeHand()
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
createRope(mouse.Target, mouse.Hit.Position, true)
end)
mouse.Button1Up:Connect(function()
createRope(nil, nil, false)
end)
The code above is an edited version of your script, it uses a “Fake hand” that’s welded to the player’s real hand. This way the rope/string is not directly attached to the player, but to the fake hand instead.
Thanks for this, I’ll use it and let you know if it works, however, I noticed that you are waiting on a child in ReplicatedStorage? Is this supposed to be a RemoteEvent?
It works however it seems to be messing with the character a bit.
Here’s a video that shows it:
As you can see the player has a seizure, and in the air it goes to a side a little bit, throwing off the player’s keys so when holding W, they go sideways.