Roblox Studio - How To Make Tycoon Money Collectors

Kinfolk Studio
Kinfolk Studio
1.4 هزار بار بازدید - 3 سال پیش - This video will show you
This video will show you how to make a Tycoon style money collector or money generator, which let the player claims the machine and collect money from it.

How To Handle Data #1 Roblox Studio - How To Handle Data #1...

Script inside the MoneyCollector Model:
local ClaimButton = script.Parent:WaitForChild("ClaimButton")
local CollectButton = script.Parent:WaitForChild("CollectButton")
local Display = script.Parent:WaitForChild("Display")
local OwnerId = script.Parent:WaitForChild("OwnerId")
local MoneyStored = script.Parent:WaitForChild("MoneyStored")

local MoneyPerTick = 50
local TickWait = 2

local ClaimDB = false
local CollectDB = false

local function GenerateMoney(PlayerId)
MoneyStored.Value =0
while OwnerId.Value == PlayerId do
 task.wait(TickWait)
 MoneyStored.Value = MoneyStored.Value + MoneyPerTick
end
end

local function onClaimButtonTouched(hit)
if OwnerId.Value ~= 0 then
 return
end
if ClaimDB == false then
 ClaimDB = true
 
 if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
  local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
  if Player then
   OwnerId.Value = Player.UserId
   
   local StartGenerate = coroutine.wrap(GenerateMoney)
   StartGenerate(Player.UserId)
   print(Player.Name.." Claimed the money collector.")
   
   MoneyStored.Changed:Connect(function(NewValue)
    Display.SurfaceGui.TextLabel.Text = tostring("$"..NewValue)
   end)
  end
 end
 
 ClaimDB = false
end
end
ClaimButton.Touched:Connect(onClaimButtonTouched)

local function onCollectButtonTouched(hit)
if OwnerId.Value == 0 then
 return
end

if CollectDB == false then
 CollectDB = true
 
 if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
  local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
  if Player then
   if Player.UserId == OwnerId.Value then
    local PlayerGold = Player:WaitForChild("SavedData"):WaitForChild("Gold")
    PlayerGold.Value = PlayerGold.Value + MoneyStored.Value
    MoneyStored.Value = 0
   end
  end
 end
 
 CollectDB = false
end
end
CollectButton.Touched:Connect(onCollectButtonTouched)
3 سال پیش در تاریخ 1400/06/25 منتشر شده است.
1,430 بـار بازدید شده
... بیشتر