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

Why do I get an Upvalue error?

Asked by
Nidoxs 190
9 years ago

This script gives this output : Workspace.Model.Script:6: attempt to index upvalue 'a' (a nil value) It's pretty self explanatory what it does.

local a = game.Players.LocalPlayer
function meltdown()
game.Workspace.Sounds.MeltdownAnnounce:Play()
wait(5)
game.Workspace.Sounds.FirstMusic:Play()
a.PlayerGui.WARNING.TextLabel.Script.Disabled = false
wait(5)
script.Parent.Explode.Enabled = true
game.Workspace.Sounds.Explode:Play()
wait(.6)
script.Parent.Explode.Enabled = false
game.Workspace.Sounds.Siren:Play()
wait(30)
game.Lighting.Ambient = Color3.new(0,0,0)
game.Lighting.OutdoorAmbient = Color3.new(0,0,0)
game.Lighting.Brightness = -5
function SearchOff(place)
    for _,part in pairs(place:GetChildren()) do
        if part:IsA("PointLight") or part:IsA("SpotLight")then
            part.Enabled = false
            part.Parent.Material = "Plastic"
            else
            SearchOff(part)
        end
    end
end


SearchOff(game.Workspace)
wait(20)
game.Workspace.Sounds.EmergPower:Play()
wait(.9)
function SearchOff2(place)
    for _,part in pairs(place:GetChildren()) do
        if part:IsA("PointLight") or part:IsA("SpotLight")then
            part.Enabled = true
            part.Parent.Material = "Neon"
            else
            SearchOff2(part)
        end
    end
end


SearchOff2(game.Workspace)
end

meltdown()

--[[local e = Instance.new("Explosion")
e.Parent = game.Workspace.Core.Core
e.Position = game.Workspace.Core.Core.Position]]--
0
You should provide the whole script; it's likely a problem outside those two lines. IDidMakeThat 1135 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
function meltdown()
game.Workspace.Sounds.MeltdownAnnounce:Play()
wait(5)
game.Workspace.Sounds.FirstMusic:Play()
for _,a in pairs (game.Players:GetPlayers()) do
a.PlayerGui.WARNING.TextLabel.Script.Disabled = false
end
wait(5)
script.Parent.Explode.Enabled = true
game.Workspace.Sounds.Explode:Play()
wait(.6)
script.Parent.Explode.Enabled = false
game.Workspace.Sounds.Siren:Play()
wait(30)
game.Lighting.Ambient = Color3.new(0,0,0)
game.Lighting.OutdoorAmbient = Color3.new(0,0,0)
game.Lighting.Brightness = -5
function SearchOff(place)
    for _,part in pairs(place:GetChildren()) do
        if part:IsA("PointLight") or part:IsA("SpotLight")then
            part.Enabled = false
            part.Parent.Material = "Plastic"
            else
            SearchOff(part)
        end
    end
end


SearchOff(game.Workspace)
wait(20)
game.Workspace.Sounds.EmergPower:Play()
wait(.9)
function SearchOff2(place)
    for _,part in pairs(place:GetChildren()) do
        if part:IsA("PointLight") or part:IsA("SpotLight")then
            part.Enabled = true
            part.Parent.Material = "Neon"
            else
            SearchOff2(part)
        end
    end
end


SearchOff2(game.Workspace)
end

meltdown()

--[[local e = Instance.new("Explosion")
e.Parent = game.Workspace.Core.Core
e.Position = game.Workspace.Core.Core.Position]]--

Now the problem here is that you cannot access localplayer through a server script. a server script runs on the server, and a localscript runs on the client. On the server of the game, since a server script doesn't run on the client, it can't get the localplayer. How do we fix this? Well, as you probably know, there is a folder in Datamodel called Players, that holds all the players. we can scroll through all of the players in game.Playersusing a pairs loop, and going to the script, and enabling them. I did this on line 6 - 8

Ad

Answer this question