Hey guys,
so before I asked a question regarding my MainModule to assign certain Avatars via a specific function, which turned out to not work due to a wrong event. Now, I'm trying to pass a parameter from my Script (In this case "plr" and "char") to the MainModule, so it can set the parent of certain items to the player's Character. I tried several things, I even tried to just put the parameters from the script in the MainModule's function, but without any succes. Here's my code:
SCRIPT
local Global = require(game.ServerScriptService.GlobalHandler)
game.Players.PlayerAdded:Connect(function(plr)
--Create Avatar
if not plr:FindFirstChild("avatar") then
local value = Instance.new("StringValue")
value.Parent = plr
value.Name = "avatar"
end
--Avatar Customization
plr.CharacterAdded:Connect(function(char)
local avatar = plr:WaitForChild("avatar")
if avatar.Value == "guitar" then
Global.GuitarAvatar()
elseif avatar.Value == "hank" then
Global.HankAvatar()
elseif avatar.Value == "secretary" then
Global.SecretaryAvatar()
elseif avatar.Value == "princess" then
Global.PrincessAvatar()
end
end)
end)
MAINMODULE
local Global = {}
--Variables
local rs = game:GetService("ReplicatedStorage")
local gdhats = game:GetService("ServerStorage").GuitarDude
--Tables (Shirt, Pants, Face)
GuitarClothes = {"http://www.roblox.com/asset/?id=398635080","http://www.roblox.com/asset/?id=382538502","rbxassetid://1016181246"}
GuitarHats = {gdhats.BackGuitar, gdhats.Bandito, gdhats.CheeseHat, gdhats.Necklace}
--Functions
function Global.GuitarAvatar()
wait(1)
--Accessories
for i,v in pairs (char:GetChildren()) do
if v.ClassName == "Accessory" or v.ClassName == "Hat" then
v:Destroy()
end
end
GuitarHats[1]:Clone().Parent = char --"Unknown global 'char'"
GuitarHats[2]:Clone().Parent = char
GuitarHats[3]:Clone().Parent = char
GuitarHats[4]:Clone().Parent = char
--Face
char.Head.face.Texture = GuitarClothes[3]
--Shirt
if not char:FindFirstChild("Shirt") then
local shirt = Instance.new("Shirt")
shirt.Parent = char
shirt.ShirtTemplate = GuitarClothes[1]
else
local shirt = char:FindFirstChild("Shirt")
shirt.ShirtTemplate = GuitarClothes[1]
end
--Pants
if not char:FindFirstChild("Pants") then
local pants = Instance.new("Pants")
pants.Parent = char
pants.PantsTemplate = GuitarClothes[2]
else
local pants = char:FindFirstChild("Pants")
pants.PantsTemplate = GuitarClothes[2]
end
end
--Events
rs.respawn.OnServerEvent:Connect(function(player)
player:LoadCharacter()
end)
return Global
Any tips on how I get rid of the "Unknown global 'char'" warning, and setting the proper parent would be appreciated!

4 comments
You could just do local char = plr.Character or plr.CharacterAdded:Wait().
Well no, that's just the problem. I can't get "plr" in the Script because adding a PlayerAdded Event wouldn't work.
Is it solo mode?
It's on both Testing and Server.