Hello, why wont this work? It does not create the IntValue nor it errors.
1 | game.Players.PlayerAdded:connect( function (plr) |
2 | local OwnsTycoon = Instance.new( 'IntValue' , game.Players:FindFirstChild(plr)) |
3 | OwnsTycoon.Value = false |
4 | OwnsTycoon.Name = 'OwnsTycoon' |
5 | end ) |
Why are you searching for the plr argument in Players? It is already defined as the player.
1 | game.Players.PlayerAdded:connect( function (plr) |
2 | local OwnsTycoon = Instance.new( 'BoolValue' , plr) |
3 | OwnsTycoon.Value = false |
4 | OwnsTycoon.Name = 'OwnsTycoon' |
5 | end ) |
You have forgotten to tell the script who the player is.
Also: an IntValue cannot have a false or true value. Only numbers. Therefore your value has to be a BoolValue.
1 | local player = game.Players.LocalPlayer |
2 | game.Players.PlayerAdded:connect( function (plr) |
3 | local OwnsTycoon = Instance.new( "BoolValue" ) |
4 | OwnsTycoon.Parent = player |
5 | OwnsTycoon.Value = false |
6 | OwnsTycoon.Name = "OwnsTycoon" |
7 | end ) |
DepressionSensei is correct. You already have the player, passed down as "plr". Finding the player would only cause problems, compared to directly affecting the player (because you already have him/her as "plr" when they join). On another note, you cannot set a IntValue to true or false. A "IntValue" stands for "Integer Value" which is commonly received as a number value. A BoolValue, or sometimes called a boolean, is a True or False value. Your code can check the value and act depending on whether it is true or false.
1 | game.Players.PlayerAdded:connect( function (plr) -- Right here, plr is the player that joined |
2 | local OwnsTycoon = Instance.new( 'BoolValue' , plr) -- This creates a new "BoolValue", right under plr(which is the player, passed down through the script) |
3 | OwnsTycoon.Value = false -- Now you are dealing with a boolean, and that can have a true/false value |
4 | OwnsTycoon.Name = 'OwnsTycoon' |
5 | end ) |
I simply explained the same thing DepressionSensei did.