--Welcome Bois, set up this thing :) ~322ita
--did some changes now it gets the tool from the serverstorage not anymore from the folder i created before.
local CashValue = script.Parent.CashValue.Value --cash value
local plr = game.Players.LocalPlayer
repeat wait() until plr:HasAppearanceLoaded()
local ItNum = plr:WaitForChild("ItemNumber"):WaitForChild("ItemNum")
local itemNumber = script.Parent.ItemNumber
local itemName = script.Parent.ItemName
local button = script.Parent
local ld = plr:WaitForChild("leaderstats"):WaitForChild("Cash")
local tool = game.ServerStorage[itemName]
dp = tool:Clone()
button.MouseButton1Click:Connect(function()
print("clicked")
button.BackgroundColor3= Color3(255, 24, 255)
wait()
button.BackgroundColor3 = Color3(255, 255, 255)
--if ItNum.Value ~= itemNumber.Value then
if ld.Value >= CashValue then
print("purchased!")
ld.Value = ld.Value - CashValue
if plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary == true then
local destroying = plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary.Parent
destroying:Destroy()
end
wait()
dp.Parent = plr.Backpack
end
-- end
end)
--Welcome Bois, set up this thing :) ~322ita
--did some changes now it gets the tool from the serverstorage not anymore from the folder i created before.
local CashValue = script.Parent.CashValue.Value --cash value
local plr = game.Players.LocalPlayer
repeat wait() until plr:HasAppearanceLoaded()
local ItNum = plr:WaitForChild("ItemNumber"):WaitForChild("ItemNum")
local itemNumber = script.Parent.ItemNumber
local itemName = script.Parent.ItemName
local button = script.Parent
local ld = plr:WaitForChild("leaderstats"):WaitForChild("Cash")
button.MouseButton1Click:Connect(function()
print("clicked")
button.BackgroundColor3= Color3(255, 24, 255)
wait()
button.BackgroundColor3 = Color3(255, 255, 255)
--if ItNum.Value ~= itemNumber.Value then
if ld.Value >= CashValue then
print("purchased!")
ld.Value = ld.Value - CashValue
if plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary == true then
local destroying = plr.Backpack:FindFirstChildWhichIsA("Tool").isPrimary.Parent
destroying:Destroy()
end
wait()
local tool = game.ServerStorage[itemName.Value]
dp = tool:Clone()
dp.Parent = plr.Backpack
end
-- end
end)
Hey! I modified your code, This will work probably.