local Button1 = workspace.Buttons.Button1
local Button2 = workspace.Buttons.Button2
local Button3 = workspace.Buttons.Button3
local Button4 = workspace.Buttons.Button4
local Button5 = workspace.Buttons.Button5
local Button6 = workspace.Buttons.Button6
local Button7 = workspace.Buttons.Button7
local Button8 = workspace.Buttons.Button8
local Button9 = workspace.Buttons.Button9
local Button10 = workspace.Buttons.Button10
local Button11 = workspace.Buttons.Button11
local Button12 = workspace.Buttons.Button12
local Button13 = workspace.Buttons.Button13
local Button14 = workspace.Buttons.Button14
local Button15 = workspace.Buttons.Button15
local Button16 = workspace.Buttons.Button16
local Button17 = workspace.Buttons.Button17
local Button18 = workspace.Buttons.Button18
local Button19 = workspace.Buttons.Button19
local Button20 = workspace.Buttons.Button20
local Button21 = workspace.Buttons.Button21
local Button22 = workspace.Buttons.Button22
local Button23 = workspace.Buttons.Button23
–Multipliers
local CollecterCashButton = workspace.Collector
local CashValueScreen = workspace.Collector.CashValueScreen.SurfaceGui.TextLabel
game.Players.PlayerAdded:Connect(function(joining) --When the player joins the game…
No, those do the exact same thing - one is just shorthand. The problem is an attempt to add an instance value - quite a few things are wrong with this code.
Have a set amount you want to add.
Then, you should modify your code slightly:
local players = game:GetService("Players")
local Button1 = workspace.Buttons.Button1
local Button2 = workspace.Buttons.Button2
local Button3 = workspace.Buttons.Button3
local Button4 = workspace.Buttons.Button4
local Button5 = workspace.Buttons.Button5
local Button6 = workspace.Buttons.Button6
local Button7 = workspace.Buttons.Button7
local Button8 = workspace.Buttons.Button8
local Button9 = workspace.Buttons.Button9
local Button10 = workspace.Buttons.Button10
local Button11 = workspace.Buttons.Button11
local Button12 = workspace.Buttons.Button12
local Button13 = workspace.Buttons.Button13
local Button14 = workspace.Buttons.Button14
local Button15 = workspace.Buttons.Button15
local Button16 = workspace.Buttons.Button16
local Button17 = workspace.Buttons.Button17
local Button18 = workspace.Buttons.Button18
local Button19 = workspace.Buttons.Button19
local Button20 = workspace.Buttons.Button20
local Button21 = workspace.Buttons.Button21
local Button22 = workspace.Buttons.Button22
local Button23 = workspace.Buttons.Button23
local CollecterCashButton = workspace.Collector
local CashValueScreen = workspace.Collector.CashValueScreen.SurfaceGui.TextLabel
local toAdd = 30 --change to however much you want them to get on touching the part
local db = false
local function addCash(hit)
if db then return nil end
local player = players:GetPlayerFromCharacter(hit.Parent)
if player then
db = true
player.leaderstats.Coins.Value += toAdd
--could also do player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + toAdd
task.wait(0.5)
db = false
end
end
local function addLeaderstats(joining) --When the player joins the game…
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = joining
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 1
Coins.Parent = leaderstats
end
players.PlayerAdded:Connect(addLeaderstats)
Button1.Touched:Connect(addCash)