Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Yeevivor4 155
8 years ago

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

Log in to vote
1
Answered by
Azmidium 388 Moderation Voter
8 years ago
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

Ad

Answer this question