game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
end)while true do
wait(2)
local drop = Instance.new("Part")
drop.Size = Vector3.new(1,1,1)
drop.Position = script.Parent.Position - Vector3.new(0,2,0)
drop.BrickColor = BrickColor.new("Bright green")
drop.Parent = workspace
drop.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.leaderstats.Cash.Value += 10
drop:Destroy()
end
end)
endlocal price = 100
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local cash = player.leaderstats.Cash
if cash.Value >= price then
cash.Value -= price
local item = game.ServerStorage.Item:Clone()
item.Parent = workspace
script.Parent:Destroy()
end
end
end)script.Parent.Velocity = Vector3.new(10,0,0)script.Parent.Touched:Connect(function(hit)
if hit.Name == "Drop" then
hit.BrickColor = BrickColor.new("Bright red")
end
end)local DataStoreService = game:GetService("DataStoreService")
local store = DataStoreService:GetDataStore("TycoonData")
game.Players.PlayerAdded:Connect(function(player)
local data = store:GetAsync(player.UserId)
if data then
player.leaderstats.Cash.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player)
store:SetAsync(player.UserId, player.leaderstats.Cash.Value)
end)