When I tested this in Studio (Tools-Test-StartServer, and Player), I got an error for line 19...:
attempt to index local 'player' (a nil value)
Code:
--SETUP--
ToolName = "One" --Exact Tool Name here.
Price = 0 --Price of the tool
Currency = "Cash" --Currency Type
--SETUP COMPLETE--
Button = script.Parent
ds = game:GetService("DataStoreService")
function CheckIfBought(name,Name)
dss = ds:GetDataStore(Name.." KM Tools")
if dss:GetAsync(name)==true then
return true
else
return false
end
end
function Buy(player)
dss = ds:GetDataStore(player.Name.." KM Tools")
stats = player.leaderstats
currency = stats:FindFirstChild(Currency)
a = game.Lighting.Tools:FindFirstChild(ToolName)
if (CheckIfBought(ToolName,player.Name) == true) then --If the player already bought the tool...
if a ~= nil then
a:Clone().Parent = player.Backpack
end
else
if currency ~= nil and currency.Value >= Price then
currency.Value = currency.Value - Price
a:Clone().Parent = player.Backpack
dss:SetAsync(ToolName,true)
end
end
end
Button.MouseButton1Click:connect(Buy)
P.S. It would also be helpful if you could tell me if this code was to work with the error being fixed. Thanks!

2 comments
The MouseButton1Click event passes absolutely nothing.
Ah, okay, I wasn't sure if it was nothing, or the mouse. Thanks for that.