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

VIP Line 7 returns to a nil value?

Asked by 10 years ago

Workspace.VIP.VIPDoorScript:7: attempt to index global 'Players' (a nil value)

Thats what it says in the output.

VIP = game.Workspace.VIP

TShirt = game.Workspace.TShirt
ID = TShirt.Graphic

function onTouched(hit)
    if Players.TShirt.ID == "http://www.roblox.com/The-Games-VIP-T-shirt-item?id=154826128" then
        VIP.Transparency = 1
        VIP.CanCollide = false
        wait(2)
        VIP.Transparency = 0
        VIP.CanCollide = true
    else
        if Players.TShirt.ID ~= "http://www.roblox.com/The-Games-VIP-T-shirt-item?id=154826128" then
            game.Workspace.Players:GetPlayers("Humanoid")
            Players.Humanoid.Health = 0
        end
        end
end

script.Parent.Touched:connect(onTouched)

I don't see whats the problem? Why?

1 answer

Log in to vote
2
Answered by 10 years ago

You haven't defined what 'Players' is.

local Players = game.Players:GetPlayerFromCharacter(hit.Parent)

Put that just under the start of the function.

0
Ahh! Thanks! Roboy5857 20 — 10y
Ad

Answer this question