I'm trying to use a ClickDetector in a part to give the player who clicks it a random weapon, but everytime I click it I get the same thing.
Code:
local gamepassID = 510675750 local weapons = game.ServerStorage.Weapons:GetChildren() local random = weapons[math.random(1, #weapons)] script.Parent.ClickDetector.MouseClick:connect(function (playerWhoClicked) local player = playerWhoClicked local mps = game:GetService("MarketplaceService") local playerHasPass = mps:PlayerOwnsAsset(player, gamepassID) if playerHasPass then random:Clone().Parent = player.Backpack else mps:PromptPurchase(player, gamepassID) end end)
Don't know why I'd have to say this, but yes, there is more than one tool in the folder (duh)
When a "server" starts in ROBLOX studio, it always has the same math.random(), also why dont you call weapon inside the MouseClick function? That would also make the random right.