Hitbox is not a valid member of Part? Help me

hi I want to ask for your help, I Created a Morph character for my game but I, have a problem in why "Hitbox is not a valid member of Part “Workspace.Morph.1”??? so what is wrong with the Script and why Hitbox in Morph are not valid members of the Section??

g
hitbox

game:GetService("ReplicatedStorage").MorphREM.MorphRmSAVE.OnClientEvent:Connect(function(MorphChr)
	if workspace.Morph:WaitForChild(MorphChr) ~= nil then
		workspace:FindFirstChild("Morph")[MorphChr].Transparency = 1
		workspace:FindFirstChild("Morph")[MorphChr].Attachment.BuyCash.Enabled = false
		workspace:FindFirstChild("Morph")[MorphChr].Hitbox.ProximityPrompt.Enabled = true
	end
end)

What is line 5? The error should be an infinite yield warning since you :WaitForChild() the object

try this


local wsMorphs = workspace.Morph
game:GetService("ReplicatedStorage").MorphREM.MorphRmSAVE.OnClientEvent:Connect(function(MorphChr)
	
	local thisMorph = wsMorphs:FindFirstChild(MorphChr) :: BasePart?
	
	local thisMorphAttachment = thisMorph and thisMorph:FindFirstChild("Attachment")
	local thisMorphBuyCashValue = thisMorphAttachment and thisMorphAttachment:FindFirstChild("BuyCash")
	
	local thisMorphHitbox = thisMorph and (thisMorph:FindFirstChild("Hitbox") or thisMorph:FindFirstChild("hitbox"))
	local thisMorphProx = thisMorphHitbox and thisMorphHitbox:FindFirstChildWhichIsA("ProximityPrompt")
	
	if thisMorph then
		
		thisMorph.Transparency = 1
		
		if thisMorphBuyCashValue then
			thisMorphBuyCashValue.Enabled = false
		end
		
		if thisMorphProx then
			thisMorphProx.Enabled = true
		end
		
	end
	
end)

1 Like

Thank you very much it works :smile: :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.