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

Why won't the value of a boolvalue change when a player walks over a part??

The BoolValue won't change values.

Important facts:

-Filtering enabled: ON

-Type of script: Server script (Lives inside of the part)

-The script that made the BoolValue: Server Script (Child to ServerScriptService)

-Name of BoolValue: IsInMatch

-API Services: ON

-Part transparency: 1

-Part CanCollide: False (You can walk through the part)

  • Ask for any more info!

  • EDIT THE GAME HERE AND FIND THE PROBLEM: Edit the game

Script inside the part:

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

The script that makes the boolValue:

game.Players.PlayerAdded:Connect(function(player)

local IsInMatch = Instance.new("BoolValue") -- Bool value to disable/enable
	IsInMatch.Name = "IsInMatch"
	IsInMatch.Parent = player

end)

Note: I deleted parts of the script which weren't related to the error.

7 comments

0

Probably you just need to use player:FindFirstChild("IsInMatch"). Is there any errors?

0

Yes, Here is the output:

0

Workspace.Platform.Script:9: ')' expected (to close '(' at line 1) near ''

0

Please accept my answer if that helped

0

It still doesn't work.

0

Try my edited one.

0

Try the new one.

2 answers

✓ Accepted answer

So you should have used wait for child, so the script can find the value correctly. You also made some other tiny errors. Here is the edited script:

script.Parent.Touched:Connect(function(hit)

        if hit.Parent:FindFirstChild("Humanoid") then
          	  local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	local match = player:WaitForChild("IsInMatch")

        match.Value = false
        elseif hit.Parent.Parent:FindFirstChild("Humanoid") then --If has hits part
            local player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
local match = player:WaitForChild("IsInMatch")
      match.Value = false
        end
end)

You also have to set your values for the isinmatch. I tested this! Accept this answer if it helped you!

8 comments

0

Workspace.Platform.Script:2: attempt to index global 'player' (a nil value)

0

Oh, sorry. Forgot to put player.

0

Still doesn't work :(

0

The var "match" has blue under line underneath it...

0

You can try to fix the problem at the game I made: https://www.roblox.com/games/2834283271/sbob12345ms-Place-Number-40

0

Thanks works only for the first time. If I change the value later and then come back it won't work.

0

wait wdym?

0

wait wdym?

As you told me the error, just put a ) character at the end in line 9, at the end of the function. An example function:

game.Players.PlayerAdded:Connect(function(player)
	--stuff
end) -- You forget there )

4 comments

0

Do you mean script.Parent.Touched?

0

Yes, in his script that's the event

0

this is the correct answer. You should accept it.

0

Its not working.

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