Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Need help completing my system?

Im having this annoying problem, And its flooding the output because its parent doesnt have a HRootPart, Is there a way i could do this without it flooding the output? This is what i put

script.Parent.Touched:Connect(function(K)
	local HR = K.Parent.HumanoidRootPart
	local hum = K.Parent.Humanoid
	if K.Parent.HumanoidRootPart.Name == "HumanoidRootPart" then
		FID.Texture = "rbxassetid://406001167"
		wait(2)
		FID.Texture = "rbxassetid://5275085975"
	end
end)

Its flooding the output and it is Extremely Annoying.

1 comment

0

Use FindFirstChild(), it simply returns nil if the instance is not found.

1 answer

✓ Accepted answer

You should replace line 4 with:

If K.Parent:FindFirstChild("HumanoidRootPart") then

And also move 2 and 3 below it so you don't run into any errors.

What you should end up with is:

script.Parent.Touched:Connect(function(K)
	if K.Parent:FindFirstChild("HumanoidRootPart") then
		local HR = K.Parent.HumanoidRootPart
		local hum = K.Parent.Humanoid
		FID.Texture = "rbxassetid://406001167"
		wait(2)
		FID.Texture = "rbxassetid://5275085975"
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.