Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with this script?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
2
Answered by 10 years ago
 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.

0
Thanks :D keitheroni 45 — 10y
Ad

Answer this question