Why won't this work? I want to give each player a random item on spawn.
Gives a random player an item when they spawn. Out of these four items. Rewrite the script if nessecary.
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) local hk = Instance.new("BoolValue", plr) hk.Value = false hk.Name = "HoldingKnife" local m = 0 repeat wait() if hk==true then local hum = chr:FindFirstChild("Humanoid") if hum then hum.Died:connect(function() hk.Value = false end) end return else hk.Value = true local o = math.random(1,4) if o==1 then local clone1 = game.Lighting.Blade:Clone() clone1.Parent = plr.Backpack elseif o==2 then local clone2 = game.Lighting.Bombos:Clone() clone2.Parent = plr.Backpack elseif o==3 then local clone3 = game.Lighting.DualKnives:Clone() clone3.Parent = plr.Backpack elseif o==4 then local clone4 = game.Lighting.InsaneKnife:Clone() clone4.Parent = plr.Backpack end end until m==10 end) end)
use Tables
and math.random
Item1 = game.Lighting.ItemName Item2 = game.Lighting.ItemName Item3 = game.Lighting.ItemName --and keep doing this until u have all the Items defined Items = {Item1, Item2, Item3} --Put all of the above Names inside --onSpawn Code (ur Code is a lil confusing, sry) SpawnItem = Items[math.random(#Items, 1)] --sry, didn't use Tables with math.random in ages now SpawnItem:clone().Parent = --however u want to contact the Player, if it's a Gui then 'LocalPlayer'
Hope I helped :D