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

Is it possible to add a BoolValue to a player's backpack?

I've attempted to add a value to a player's backpack, but when I reference to it in a script it outputs the error "BoolValue is not a valid member of BackPack". When that didn't work I inserted a script, then a localscript when it didn't work, into the workspace and had it create a BoolValue that was false, and set the parent to the PLAYER. Can anyone tell me why it's not working? Thanks for your help ;)

Here's an example of my code for the script that creates a BoolValue and has its parent be the Player

game.Players.PlayerAdded:connect(function(player)
	local aiu = Instance.new("BoolValue")
	aiu.Name = "ActionInUse"
	aiu.Value = false
	aiu.Parent = player

1 answer

First off, use a server Script. LocalScripts don't run in workspace.

Second, you forgot an end and a closing parenthesis at the end of your script.

	. . .
end)


Your main problem is just that when you try to access the value, you get the error "BoolValue is not a valid member of BackPack". The way the output works, this means that somewhere you had code something like this,

player.BoolValue

Actually using the word BoolValue.


In Lua, the dot searches for an object or property by name, so if there's nothing named "BoolValue" in player, the script will throw an error.

There is nothing named "BoolValue" in player.

Because on line 3 you change the name,

aiu.Name = "ActionInUse"

So now you have to access it with the name "ActionInUse"

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