Why is my ServerScriptService script, not finding a part?

Uh? Currently I’m trying a new method for a hitbox, and to get the actual Hitbox for the character, it’s very odd how it just doesn’t say it exists?

local CH = SSS.PlayerSpawned.SpawnINItems



game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		task.wait()
		Character.Parent = workspace.LivingThings
		
		CH:FindFirstChild("CharsHitbox").Parent = game.workspace
		CH:FindFirstChild("CharsHitbox").Name = Player.Name.. "Hitbox"

		
		local Attach1, Attach2, Attach3, Attach4, Attach5, Attach6 = Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"),Instance.new("Attachment")
		Attach1.Parent = Character.HumanoidRootPart
		Attach2.Parent = Character.Head
		Attach3.Parent = Character["Right Leg"]
		Attach4.Parent = Character["Left Leg"]
		Attach5.Parent = Character["Right Arm"]
		Attach6.Parent = Character["Left Arm"]
		
		local Weld = Instance.new("Motor6D")
		
		Character:SetAttribute("IsBlocking", false)
		
		Character:SetAttribute("CanAttack", false)
		
		Character:SetAttribute("Running", false)
		
		Character:SetAttribute("Dashing", false)
		
		Character:SetAttribute("Clash", nil)
		
		Character:SetAttribute("Parry", false)
		
		Character.Humanoid.WalkSpeed = 13
		
		Weld.Part0 = Character.HumanoidRootPart
		Weld.Part1 = workspace.LivingThings:FindFirstChild(Player.Name.. "Hitbox")

		local Jeh = Enum.HumanoidHealthDisplayType.AlwaysOff == true
	end)
end)

Maybe try using :WaitForChild() on both CH and the Player’s Character’s Parts. (Right Leg, Left Arm, etc) Not sure if doing this would work.

Oh, I should’ve clarified where the issue is taking place,

		CH:FindFirstChild("CharsHitbox").Parent = game.workspace
		CH:FindFirstChild("CharsHitbox").Name = Player.Name.. "Hitbox"

This is where the actual issue happening.

Does the “CharsHitbox” BasePart is actually there? Also, Is the script inside ServerScriptService? Maybe you could try cloning the Hitbox everytime the Player’s Character’s is added and then modify it.

image
Yeah, it’s there which is even weirder. It’s saying it as if it can’t see within folders, but the combat module was easily able to access it’s Hitbox.

1 Like

Try doing as i said above, Reference the Hitbox on the Top of the script, And then Clone it whenever the Character is added. Try also adding a WaitForChild() on the CH variable.

local CH = SSS.PlayerSpawned.SpawnINItems:WaitForChild("CharsHitbox", 5)



game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		task.wait()
		local Hitbox = CH:Clone()
		
		Character.Parent = workspace.LivingThings
		
		Hitbox.Parent = game.workspace
		Hitbox.Name = Player.Name.. "Hitbox"

		
		local Attach1, Attach2, Attach3, Attach4, Attach5, Attach6 = Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"),Instance.new("Attachment")
		Attach1.Parent = Character.HumanoidRootPart
		Attach2.Parent = Character.Head
		Attach3.Parent = Character["Right Leg"]
		Attach4.Parent = Character["Left Leg"]
		Attach5.Parent = Character["Right Arm"]
		Attach6.Parent = Character["Left Arm"]
		
		local Weld = Instance.new("Motor6D")
		
		Character:SetAttribute("IsBlocking", false)
		
		Character:SetAttribute("CanAttack", false)
		
		Character:SetAttribute("Running", false)
		
		Character:SetAttribute("Dashing", false)
		
		Character:SetAttribute("Clash", nil)
		
		Character:SetAttribute("Parry", false)
		
		Character.Humanoid.WalkSpeed = 13
		
		Weld.Part0 = Character.HumanoidRootPart
		Weld.Part1 = workspace.LivingThings:FindFirstChild(Player.Name.. "Hitbox")

		local Jeh = Enum.HumanoidHealthDisplayType.AlwaysOff == true
	end)
end)

Changing it like this, doesn’t even seem to spawn in the hitbox, and it’s as if it’s ignored.

Just for curiosity, Why are you setting the Character’s Parent to the LivingThings folder? I don’t think that that’s really needed. Maybe try also changing the CH variable to this:

local CH = script:WaitForChild("SpawnINItems", 5):WaitForChild("CharsHitbox", 5)

It’s needed for the seperate combat script. Also, I’ll see how that works out.

Well, this made no difference, and I even changed the part to workspace and nothing seemed to change.

Try this; (waiting for the character to load fully).

local CH = SSS.PlayerSpawned.SpawnINItems



game.Players.PlayerAdded:Connect(function(Player)
		task.wait()
                local Character = Player.Character or Player.CharacterAdded:Wait()
		Character.Parent = workspace.LivingThings
		
		CH:WaitForChild("CharsHitbox").Parent = game.Workspace
		CH:WaitForChild("CharsHitbox").Name = Player.Name.. "Hitbox"

		
		local Attach1, Attach2, Attach3, Attach4, Attach5, Attach6 = Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"), Instance.new("Attachment"),Instance.new("Attachment")
		Attach1.Parent = Character.HumanoidRootPart
		Attach2.Parent = Character.Head
		Attach3.Parent = Character["Right Leg"]
		Attach4.Parent = Character["Left Leg"]
		Attach5.Parent = Character["Right Arm"]
		Attach6.Parent = Character["Left Arm"]
		
		local Weld = Instance.new("Motor6D")
		
		Character:SetAttribute("IsBlocking", false)
		
		Character:SetAttribute("CanAttack", false)
		
		Character:SetAttribute("Running", false)
		
		Character:SetAttribute("Dashing", false)
		
		Character:SetAttribute("Clash", nil)
		
		Character:SetAttribute("Parry", false)
		
		Character:WaitForChild("Humanoid").WalkSpeed = 13
		
		Weld.Part0 = Character:WaitForChild("HumanoidRootPart")
		Weld.Part1 = game.Workspace.LivingThings:WaitForChild(Player.Name.. "Hitbox")

		local Jeh = Enum.HumanoidHealthDisplayType.AlwaysOff == true -- p.s: if it still doesn't work, try removed the "equal to" and only putting one equal sign.
end)

Infinite yield possible on ‘ServerScriptService.PlayerSpawned.SpawnINItems:WaitForChild(“CharsHitbox”)’

Is the new thing I’m getting now.

i’m only assuming that PlayerSpawned is the script that you’re providing here.
maybe try just doing script.SpawnINItems because serverscriptservice likes to have index troubles

That’s why I had to come here in the first place, I tried the method already.

Can you try this

local CHclone = CH:WaitForChild("CharsHitbox"):Clone()
CHclone.Parent = workspace
CHclone.Name = Player.Name.. "Hitbox"

Yeah, still nothing changed. The hitbox ain’t there.

as far as i can see you don’t parent the Weld to anything so the hitbox clone just falls down immediately

but also i don’t udnerstand why you are even making these hitboxes to begin with

Better method of Spatial Queries, looped through less to get a better effect. Andddd, it’s fixed. Thank you for your assistance.