This script is in a regular (non-local) script, and is supposed to equip a weapon when a game begins.
Everything is defined, however, nothing works. I have no idea why, as output has given me nothing.
Can someone please help me?
Here's the script:
local Player = script.Parent.Parent local GUI = script.Parent:WaitForChild("Loadout_GUI") local Playing = game.ServerScriptService.MainGame:WaitForChild("Playing") local P1 = Player.Classes[GUI.Classy.Value]:WaitForChild("Primary") local S = Player.Classes[GUI.Classy.Value]:WaitForChild("Secondary") while wait(0.1) do if Playing.Value == true then local Primary = game.ServerStorage.Weapons[P1.Value]:clone() local Secondary = game.ServerStorage.Weapons[S.Value]:clone() Primary.Parent = Player.Backpack Secondary.Parent = Player.Backpack Player.CameraMode = "LockFirstPerson" Player.Character.Humanoid:EquipTool(Player:WaitForChild("Backpack"):WaitForChild(Primary.Name)) script:Destroy() end end
You may have an infinite yield or Playing may not be true in ServerScriptService.
If GUI is a ScreenGui in StarterGui, then you need to add an additional "Parent" to Player.
local Player = script.Parent.Parent.Parent --script.Parent = ScreenGui --script.Parent.Parent = StarterGui --script.Parent.Parent.Parent = Player
Try assertion as well:
--This code is based on the fact everything in your code is valid and everything is defined. assert(game.Players:FindFirstChild(script.Parent.Parent.Name), 'Could not find a Player (Player).') assert(script.Parent:FindFirstChild 'Loadout_GUI', 'Could not find Loadout_GUI (ScreenGui).') assert(game.ServerScriptService:FindFirstChild 'MainGame', 'Could not find MainGame (Object).') assert(game.ServerScriptService.MainGame:FindFirstChild 'Playing', 'Could not find Playing (BoolValue).') assert(script.Parent.Loadout_GUI:FindFirstChild 'Classy', 'Could not find Classy (Value).') assert(Player:FindFirstChild 'Classes', 'Could not find Classes (Object).') assert(Player.Classes[Gui.Classy.Value]:FindFirstChild 'Primary', 'Could not find Primary (Object).') assert(Player.Classes[Gui.Classy.Value]:FindFirstChild 'Secondary', 'Could not find Secondary(Object).')