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

What does it mean when i attempt to call a _G. function with a "nil" value? (WARNING: LOTS OF CODE)

Asked by 6 years ago

i have 3 scripts all stringed together, but for some reason, it wont let me call my _G. functions. It calls them a "nil" value. "Players.SweetAsCreampie.PlayerGui.Buttony:36: attempt to call field 'CancelTransform' (a nil value)"

here is the the three local scripts in StarterGui Buttony:

local UIS = game:GetService('UserInputService')
local pressing
local Energy = 90
local player = game.Players.LocalPlayer
local character = player.Character

if not player or not character.Parent then
    character = player.CharacterAdded:wait()
end
done = false
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent)
    if not gameProcessedEvent then
        if inputObject.KeyCode == Enum.KeyCode.C then

            pressing = true
            while pressing do
                if done == false then
                _G.FIRE()               
                _G.Squat()
                wait(2)
                done = true
                _G.TransformReady()
                else
                _G.PowerSquat()

                wait(5.2)
                Energy = Energy + 1
                end
                    end
                    end
                    _G.GetEnergy(Energy)
            print('Charging....')
    end
    _G.NOFIRE()
    done = false
    _G.CancelTransform()
    end)
    _G.NOFIRE()
    done = false
    _G.CancelTransform()

UIS.InputEnded:connect(function(inputObject, gameProcessedEvent)
    if not gameProcessedEvent then
        if inputObject.KeyCode == Enum.KeyCode.C then
            pressing = false
            print('u stopped pressing :)')
            _G.NOFIRE()
        end
    end
end)

Flame:

local player = game.Players.LocalPlayer
local character = player.Character
local enraged = false
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end
local torso = character.LowerTorso
local fire = Instance.new("Fire")
fire.Parent = torso
fire.Enabled = false
fire.Heat = 6
fire.Size = 6

local FireOn = false

_G.FIRE = function()
    fire.Enabled = true
    if enraged == false then
    fire.Color = Color3.new(255,255,255)
    fire.SecondaryColor = Color3.new(255,255,255)
    end 
end
_G.Transform = function()
    enraged =true
end
_G.NOFIRE = function()
    if enraged == true then

    else
    fire.Enabled = false
    end
end

and finally, Enragements:

local player = game.Players.LocalPlayer
local character = player.Character
local Ready = false
_G.TransformReady = function()
    Ready = true
end
_G.CancelTransform = function()
    Ready = false
end

if not character or not character.Parent then
    character = player.CharacterAdded:wait()
end
local torso = character.LowerTorso
local fire = Instance.new("Fire")
fire.Parent = torso
fire.Enabled = false
fire.Heat = 16
fire.Size = 10
fire.Enabled = false
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent)
    if not gameProcessedEvent then
        if inputObject.KeyCode == Enum.KeyCode.G then
            if Ready == true then
                fire.Enabled = true
                fire.Color = Color3.new(240,0,0)
                fire.SecondaryColor = Color3.new(255,0,0)
            end         
            end
        end

`

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
6 years ago

Well first of all, not all the scripts runs in parallel. Because you are defining functions in different scripts you might want to wait for the corresponding function to exist and be added by the other scripts. For example, you might wait for your transform function like this:

repeat wait() until _G.transform
Ad

Answer this question