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

When player walks over part, part won't change the BoolValues' value?

When a player walks over this part (In workspace) the part wouldn't change the value of a BoolValue.

Important facts: Filtering enabled ~ On API services ~ on Type of script ~ script the part is a child to workspace

Here is the script:

function OnTouch(hit)
    if hit then
        local player = nil

        -- Checking to see if the part that hit it is a character
        if hit.Parent:FindFirstChild("Humanoid") then
            player = game.Players:GetPlayerFromCharacter(hit.Parent)
        -- Special case where a hat hits the spawn rather than a limb
        elseif hit.Parent.Parent:FindFirstChild("Humanoid") then
            player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
        end

        -- If a player was found through all the checking we did prior to this
        if player then
            player.IsInMatch.Value = false
        end
    end
end

local Spawn = script.Parent -- no need for FindFirstAncestor
Spawn.Touched:Connect(OnTouch)

Why doesn't the value change???

1 comment

0

player:WaitForChild("IsInMatch") or player:FindFirstChild("IsInMatch")

1 answer

Compiled the script and fixed up anything that may have been the issue, try this:

script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            local player = game.Players:GetPlayerFromCharacter(hit.Parent) --If hit is player
		player.IsInMatch.Value = false
        elseif hit.Parent.Parent:FindFirstChild("Humanoid") then --If hat hits part
            local player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
		player.IsInMatch.Value = false
        end
end

2 comments

0

Hmmm it doesn't seem to be working...

0

Make sure that a server script is inserting the "IsInMatch" and not a local script. Also make sure it is a "BooleanValue" otherwise setting it to false is not going to do anything unless you had it a "StringValue" and you set the actual text to "False" instead of the code to false

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