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

Instance.new stops working when inserting a table, and make a value = to the new instance?

For some reason my script breaks, nothing in it works, and the new bool value i added to the player stops working, when there is a table with a value that is = to the instance.new that inserted the boolvalue into the player.

Here is what i did

game.Players.PlayerAdded:Connect(function(players)
 local save_values = {
["haschar"] = players:WaitForChild("Has_Char")
}
song:Play()
song.Looped = true
local has_char = Instance.new("BoolValue", players)
has_char.Name = "Has_Char"
players.CharacterAdded:Connect(function(character)
      end)
 end)

I dont understand why this wont work? it looks like it should to me. Any help would be appreciated. Thanks

3 comments

0

'Players' was never defined, and you'd need to target the local player too.

0

Side Note: The 'CharacterAdded' method is redundant according to it having an empty scope.

0

Thats what it does, players is the local player, and is also = to game.Players.LocalPlayer basically but on server

1 answer

✓ Accepted answer

Check if it is in a local script, as the code looks fine. But parenting something in the instance.new line is deprecated, so define it as a boolvalue then parent it on a seperate line.

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