Hey!
Recently (10 days ago) I released my game, and I got an error (kinda).
My weldconstraint keeps flinging me.
Does anybody know a fix? (Using a weld will not work due to NPCs who are attracted to the part, without the weldconstraint, everything’s broken. )
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Part = Instance.new("Part", Character)
Part.Name = "Part"
local weld = Instance.new("WeldConstraint", Part)
Part.Position = Character.HumanoidRootPart.Position
Part.Size = Vector3.new(4, 5, 2)
Part.Transparency = 1
weld.Part0 = Character.HumanoidRootPart
weld.Part1 = Part
Part.CanCollide = false
Character.Humanoid.Died:Connect(function()
Character:FindFirstChild("Part"):Destroy()
end)
end)
end)
1 Like
Winbloo
(Winbloo)
June 22, 2021, 1:44pm
#2
Have you set your weld’s position?
You should also change the weld’s position after you change the Part’s position, or the position will be set to the previous one before your part has been positioned to it’s new place.
1 Like
Xperty_z
(Xpert)
June 22, 2021, 2:01pm
#3
the Script generates a Part
and places it in the same position as the HumanoidRootPart
, right?
remember that there are collisions, so disable collisions for this Part
before moving it to the HumanoidRootPart
2 Likes
Trying this out now, thanks.
msglongermsglongermsglongermsglonger
1 Like
Video of what happens:
Both your suggestions did not work… very sad, not gonna lie lol. ( @Winbloo )
Winbloo
(Winbloo)
June 22, 2021, 2:16pm
#6
How did the script look like when you tested the solutions?
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local AttractPart = Instance.new("Part", Character)
AttractPart.Name = "AttractPart"
local weld = Instance.new("WeldConstraint", AttractPart)
AttractPart.Size = Vector3.new(4, 5, 2)
AttractPart.Transparency = 1
AttractPart.CanCollide = false
AttractPart.Position = Character.HumanoidRootPart.Position
weld.Part0 = Character.HumanoidRootPart
weld.Part1 = AttractPart
Character.Humanoid.Died:Connect(function()
Character:FindFirstChild("AttractPart"):Destroy()
print("Removed")
end)
end)
end)
Xperty_z
(Xpert)
June 22, 2021, 2:20pm
#8
oh
so I don’t know what can be done
but try using Weld
instead of WeldConstraint
and see what happens
and check that the Part is not Anchored
Using a weld will not work due to NPCs who are attracted to the part, without the weldconstraint, everything’s broken.
(The part is also unanchored.)
Xperty_z
(Xpert)
June 22, 2021, 2:22pm
#10
oh
so unfortunately i can’t help
1 Like
Xperty_z
(Xpert)
June 22, 2021, 2:24pm
#11
is this system using any other scripts besides the one you showed?
No, I fixed it but maybe I didn’t fix.
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local AttractPart = Instance.new("Part", Character)
AttractPart.Name = "AttractPart"
local WeldConstraint = Instance.new("WeldConstraint", Character.AttractPart)
Character.AttractPart.Size = Vector3.new(4, 5, 2)
Character.AttractPart.Transparency = 0.5
Character.AttractPart.CanCollide = false
Character.AttractPart.Anchored = false
Character.AttractPart.Position = Character.HumanoidRootPart.Position
WeldConstraint.Part0 = Character.HumanoidRootPart
WeldConstraint.Part1 = Character.AttractPart
Character.Humanoid.Died:Connect(function()
Character:FindFirstChild("AttractPart"):Destroy()
end)
while wait(1) do
if Character:FindFirstChild("AttractPart") then
WeldConstraint:Destroy()
Character.AttractPart.Position = Character.HumanoidRootPart.Position
local WeldConstraint2 = Instance.new("WeldConstraint", Character.AttractPart)
WeldConstraint2.Part0 = Character.HumanoidRootPart
WeldConstraint2.Part1 = Character.AttractPart
else
warn("No AttractPart")
end
end
end)
end)
a4_onym
(mehmadios)
June 22, 2021, 3:09pm
#13
Hello! I’ve tested and made some changes on your code and it didn’t fling me.
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Part = Instance.new("Part")
Part.Parent = Character
Part.Name = "Test"
local weld = Instance.new("WeldConstraint")
weld.Parent = Part
Part.Position = Character.HumanoidRootPart.Position
Part.Size = Vector3.new(4, 5, 2)
Part.Transparency = 1
weld.Part0 = Character.HumanoidRootPart
weld.Part1 = Part
Part.CanCollide = false
Part.Anchored = false
Character.Humanoid.Died:Connect(function()
Character:FindFirstChild("Test"):Destroy()
end)
end)
end)
All I’ve done was making the Part Unanchored. It has worked well on the studio, I hope your problem gets fixed.
3 Likes
a4_onym
(mehmadios)
June 22, 2021, 3:13pm
#14
Besides this, you can remove the .Died part, when character dies, all of the Parts or other things inside the character gets destroyed.
2 Likes