So here is the first script. This is the shop script that my friend uses, but the one thing that isn’t working is in the bottom,
mon = Player.leaderstats.Wallet
if mon.Value >= Guns[CurrentValue].Amount then
mon.Value = mon.Value - Guns[CurrentValue].Amount```
And the first mon has a blue underline(error underline for me). I have a separate leaderstats script, 1 is an autogiver after a specified amount of time, the other is the actual leaderstats script. Those will be listed below the main script.
```local GamePass = 0
local CurrentGroup = 0
local Guns = {
["AR Pistol"] = {
Amount = 10000;
Image = 0;
};
["AR Rifle"] = {
Amount = 15000;
Image = 0;
};
["Tec-9"] = {
Amount = 10500;
Image = 0;
};
["Colt Pistol"] = {
Amount = 10;
Image = 0;
};
["Glock"] = {
Amount = 30000;
Image = 0;
};
}
Comma = function(x)
local a = x
while true do
a, k = string.gsub(a, "^(-?%d+)(%d%d%d)", '%1,%2')
if k == 0 then break end
end
return a
end
script.Parent.Touched:connect(function(Part)
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
spawn(function()
if Player then
if not Player.PlayerGui:FindFirstChild("GunGui") then
local CurrentValue = ""
for i, v in next, Guns do CurrentValue = i break end
local Gui = script.Parent.GunGui:Clone()
Gui.Parent = Player.PlayerGui
local Holder = Gui.Holder
local ScrollingFrame = Holder.ScrollingFrame
local HowMany = 0
for i, v in next, Guns do HowMany = HowMany + 1 end
ScrollingFrame.CanvasSize = UDim2.new(0,0,0,5 + (35 * HowMany))
local Buy = Holder.Buy
Buy.MouseButton1Down:connect(function()
if Player:IsInGroup(CurrentGroup)
then
mon = Player.leaderstats.Wallet
if mon.Value >= Guns[CurrentValue].Amount then
mon.Value = mon.Value - Guns[CurrentValue].Amount
game.ServerStorage:FindFirstChild(CurrentValue):Clone().Parent = Player.Backpack
end
end
end)
local Close = Holder.Close
Close.MouseButton1Down:connect(function() Gui:Destroy() end)
local Thumbnail = Holder.Thumbnail
local Amount = Holder.Amount
local GunName = Holder.GunName
Switch = function()
Thumbnail.Image = "http://www.roblox.com/asset/?id=" .. Guns[CurrentValue].Image
Amount.Text = "$" .. Comma(Guns[CurrentValue].Amount)
GunName.Text = CurrentValue
end
Switch()
local Count = 0
for i, v in next, Guns do
local Sample = Instance.new("TextButton", ScrollingFrame)
Sample.Name = i
Sample.Position = UDim2.new(0, 5, 0, 5 + (35 * Count))
Sample.Size = UDim2.new(0, 130, 0, 30)
Sample.BackgroundColor3 = Color3.new(0, 0, 0)
Sample.BorderSizePixel = 0
Sample.Text = i
Sample.Font = Enum.Font.SourceSans
Sample.FontSize = Enum.FontSize.Size14
Sample.TextColor3 = Color3.new(1, 1, 1)
Sample.MouseButton1Down:connect(function()
CurrentValue = i
Switch()
end)
Count = Count + 1
end
end
else
game:GetService("MarketplaceService"):PromptPurchase(Player, GamePass)
end
end)
end)
--[[
~ ~
Written
By
Bassics
~ ~
--]]
AutoCashGiverScript:
```amount = 50
timedelay = 120
currencyname = "Wallet"
while true do
wait(timedelay)
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("leaderstats") then
v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
end
end
end
Main Leaderstats Script: (leaderstats name value is Wallet)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Wallet = Instance.new("IntValue", leaderstats)
Wallet.Name = "Wallet"
Wallet.Value = DataStore:GetAsync(plr.userId) or 0
Wallet.Changed:Connect(function()
DataStore:SetAsync(plr.userId, Wallet.Value)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
DataStore:SetAsync(plr.userId, plr.leaderstats.Points.Value)
end)```
The shop GUI works and pops up, its just the buy button that isn't functioning correctly. There is another GUI linked with the top script, the GUI script, and the GUI works but when I try to buy it just doesn't do anything. I have the money and everything I waited the 2 minutes set for that variable, and it still isn't working. I know its something with the leaderstats script being linked with the mon variable, so please help and I am all ears!
Thanks!