For the past 2 days i’ve been making a dash system. I’m almost done, and just need to get over this one hitch. A part is supposed to be welded to the player to act as a hitbox of sorts. Whenever I run the script, it says I need a primary part. The character model isn’t capable of having primary parts, though.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local RP = char.HumanoidRootPart
local T = char.LowerTorso
local LT = Instance.new("Part", workspace)
char.PrimaryPart = T
LT.Size = Vector3.new(1.4, 1.8, 0.85)
LT.Name = "PlayerHitBox"
LT.Position = Vector3.new(187, 8.5, 122)
local partA = RP
while true do
RP.Parent = char
wait(0.01)
end
--local partB = char.HumanoidRootPart
local partB = LT
--partA.Position = Vector3.new(0, 10, 0)
--partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
wait(0.01)
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
end)
end)
Thanks for trying to help! The problem wasn’t in the loop, but rather because I was setting the lower torso as my primary part. It’s working fine now that I swapped it to lower torso being the weld in the HRP being the primary part. (Although the lower torso lost its shape. Is there a way to fix that?)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local RP = char.HumanoidRootPart
local T = char.LowerTorso
local LT = Instance.new("Part", workspace)
char.PrimaryPart = RP
T.Size = Vector3.new(1, 0.4, 1)
LT.Size = Vector3.new(2.5, 5, 0.5) -- dont alter. It's perfect tbh
LT.Transparency = 0.4 -- set this to 0. it's 0.4 for visual representation of hitbox
LT.BrickColor = BrickColor.new("Bright green")
LT.CanCollide = false -- biggie. Cant have it dicate our non dash movement
LT.Name = "PlayerHitBox"
LT.Position = Vector3.new(171.75, 5.996, 105.25) -- should be 1.5 studs away on z axis. This position should change with the actual spawn
LT.Massless = true -- also a biggie. If its off we go flying
local partA = T
spawn(function()
while true do
RP.Parent = char
--pos is 171.75, 3.996, 105.25
wait(0.01)
end
end)
--local partB = char.HumanoidRootPart
local partB = LT
--partA.Position = Vector3.new(0, 10, 0)
--partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
T.Transparency = 1
wait(0.01)
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
end)
end)