Hello Everyone!
I needed to use a variable I declared in a script in another script, but I didn't know how, some
some people said use _G but it doesn't seem to work for me, can you guys tell me how to do it?
Script 1:
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
_G.TheClone = game.ServerStorage.Invisibility:clone()
local gamePassID = 20730613 --Replace this set of numbers with your gamepass id
function onPlayerSpawned(player)
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
end)
-- The script below is for checking whether or not the player has the gamepass.
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true and player.Team == Teams.Runners then
TheClone.Parent = player.Backpack i
end
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()
onPlayerSpawned(player)
end)
end)
Players.PlayerSpawned:Connect(onPlayerSpawned)
Script 2:
local tool = script.Parent
local Players = game:GetService("Players")
local localplayer = Players.LocalPlayer
char = _G.TheClone.Parent
tool.Equipped:Connect(function()
tool.Activated:Connect(function()
local function setTransparency(char, value)
for _, child in pairs(char:GetChildren()) do
if child:IsA('Hat') and child:FindFirstChild("Handle") then
child = child.Handle
elseif child:IsA('BasePart') then
child.Transparency = value
end
end
end
local enabled = true
local char = _G.TheClone.Parent
if char then
local head = char:FindFirstChild("Head")
local face = head:FindFirstChild("face")
if enabled and head and game.Players:GetPlayerFromCharacter(char) then
enabled = false
for t = 0, 1, .1 do
if face then face.Transparency = t end
setTransparency(char, t)
wait(0.1)
end
wait(10)
for t = 1, 0, -.1 do
if face then face.Transparency = t end
setTransparency(char, t)
wait(0.1)
end
wait(2)
enabled = true
end
end)
end)
end)

3 comments
plz help I am a beginner
_G can't pass the client / server boundary. In other words, the client has its own _G table and the server has its own _G table.
gonna try that