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

How do you find a BoolValue inside a person's character if you hit a brick?

Hello, thank you for reading. What I'm trying to do is make a door -- which is a brick -- where if you pass through a door, and a BoolValue that you hold, named "Solitary", is true then you will be teleported back to the Jail Position.

The BoolValue "Solitary" is inside another Value called "slots" and "slots" is in another value called playerstats.

h = hit.Parent
print(h.Name)
if h then
if h == nil then return end
if h:FindFirstChild("playerstats").slots.Solitary.Value == nil then return end
if h:FindFirstChild("playerstats").slots.Solitary.Value == true then
	h:MoveTo(game.Workspace.Jail.Position)
		end
	end
end

script.Parent.Touched:connect(onTouched)

1 answer

✓ Accepted answer
function onTouched(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local solitary = h.Parent.slots:FindFirstChild("Solitary")
		if solitary then
			if solitary.Value then
				h.Parent:MoveTo(game.Workspace.Jail.Position)
			end
		end
	end
end

script.Parent.Touched:connect(onTouched)

Hope this helped!

Sincerely, jmanrock123

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