so basically I have 143 items and I want to randomly give the player five of these items when they spawn, but I can't figure it out. Right now the script does nothing for some reason. Right now it's in Starter Character Scripts.
What I have so far:
local Rstore = game.getservice("ReplicatedStorage") local count = 0 local p = game.players.localplayer while count >= 5 do r = math.random(1,143) local Item = Rstore:GetChildren() local chosenItem = Item[math.random(1,143)] local GiveItem = chosenItem:Clone() GiveItem.parent = p.Backpack count = count + 1 end
Maybe its your capitalization, Lua is quite picky so that must be the case check you output bar for any errors, i can point out "players" to be "Players" and "localplayer" into "LocalPlayers" i can also see "getservice" you can turn into "GetService" unless you give me a error i can't really figure out much.
Change "getservice" to GetService, "players" to "Players" and "localplayer" to "LocalPlayer" as Lua is case-sensitive.
The While loop will not run as count(which is zero)>=5 is not true so change that to count<=5
Hope this helps