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

What is wrong with this script?

So, I'm quite new to making tables and I am not quite sure how they work yet, so I have been doing some experimenting. I made a script using tables to try it out, but I don't know what's wrong and why it's wrong.

Code:

local invis = { --table

["BlackKnightXx"] = true,
["InfinitySoldier"] = true

}

game.Players.PlayerAdded:connect(function(player) --player joins
	wait(5) --wait for character
	if player.Name == invis then --if player is on the invis table
		local char = player.Character --fetching character
		char.Head.Transparency = 1 --invisible head
	end
end)

1 answer

✓ Accepted answer
 local invis = { --table

["BlackKnightXx"] = true,
["InfinitySoldier"] = true

}

game.Players.PlayerAdded:connect(function(player) --player joins
    wait(5) --wait for character
    if invis[player.Name] then --if the Player is in the invis table.
        local char = player.Character --fetching character
        char.Head.Transparency = 1 --invisible head
    end
end)

You index a table using []. Indexes can be numerical, string, or any other data type.

1 comment

0

Thanks :D

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