Global variable help

first local script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

repeat wait() until script.Parent.Protect

while wait() do

print(ReplicatedStorage:FindFirstChild("AntiCheat"..tostring(script.Parent.Protect.Value)))

_G.AntiCheat = ReplicatedStorage:FindFirstChild("AntiCheat"..tostring(script.Parent.Protect.Value))

end

Second local script:

local AntiCheatEvent = _G.AntiCheat

print(AntiCheatEvent)
AntiCheatEvent:FireServer()

problem: print(AntiCheatEvent) prints nil why ?

There isn’t a reason here to use _G.

The issue is probably that the second local script runs before the first one, or it’s caused by the wait() in the first local scripts.

1 Like