Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make an Auto Cash Collect script for my tycoon game?

I am making a tycoon game called Minecraft Tycoon, that uses Zednov's Tycoon Kit. Doesn't anyone know how to make it so you don't need to step on that Cash Collector brick to get the money?

3 answers

My advice in your position is don't use tycoon kits they aren't as customizable as they seem to appear if you want to get a job done it's better to just do it yourself. It may take you some time but in the long run, I can promise you it's worth the time and effort. Just start by learning basic Lua and move up from there.

If this helps an upvote and solve would be appreciated :)

  • Best Regards, - Syn

3 comments

0

Well yes, not using Tycoons Kits might be better, but i have seen and played some Roblox games that use Zednov's Tycoon Kit too but they actually have an auto cash collect script too, like Farm Tycoon and Bunny Tycoon.

0

Yes, I never said you couldn't do it. You just need to be able to understand scripts themselves. If you do understands scripts you can go edit tycoon kit script to implement what you want.

0

Yeah, I understand scripting but the problem is that I don't exactly know what should be written in the script and where the script should be put in. Maybe you know any people that understand scripting an auto cash collect for a tycoon?

add a bool value to your tycoon team then rename it AutoCollect then set the value to true then lol its correct change the purchase handler to what looks like this :

--[[
	All configurations are located in the "Settings" Module script.
	Please don't edit this script unless you know what you're doing.
--]]
local Objects = {}
local TeamColor = script.Parent.TeamColor.Value
local Settings = require(script.Parent.Parent.Parent.Settings)
local Money = script.Parent.CurrencyToCollect
local Debris = game:GetService('Debris')
local Stealing = Settings.StealSettings
local CanSteal = true -- don't change or else you won't be able to steal currency

script.Parent.Essentials.Spawn.TeamColor = TeamColor
script.Parent.Essentials.Spawn.BrickColor = TeamColor

function Sound(part,id)
	if part:FindFirstChild('Sound') then
		return
	else
		local Sound = Instance.new('Sound',part)
		Sound.SoundId = "rbxassetid://"..tostring(id)
		Sound:Play()
		delay(Sound.TimeLength, function()
			Sound:Destroy()
		end)
	end
end

--Parts that fall into the collector(s) get processed
for i,v in pairs(script.Parent.Essentials:GetChildren()) do
	if v.Name == "PartCollector" then
		v.Touched:connect(function(Part)
			local player = script.Parent.Owner.Value
			if Part:FindFirstChild('Cash') then
			if script.Parent.AutoCollect.Value == true then
		game.ServerStorage.PlayerMoney:FindFirstChild(player.Name).Value = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name).Value + Part.Cash.Value
		elseif script.Parent.AutoCollect.Value == false then
			script.Parent.CurrencyToCollect.Value = script.Parent.CurrencyToCollect.Value + Part.Cash.Value
		end
				Debris:AddItem(Part,0.1)
			end
		end)
	end
end


--Player Touched Collector processor
deb = false
script.Parent.Essentials.Giver.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player ~= nil then
		if script.Parent.Owner.Value == player then
			if hit.Parent:FindFirstChild("Humanoid") then
				if hit.Parent.Humanoid.Health > 0 then
					if deb == false then
						deb = true
						script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Bright red")
						local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
						if Stats ~= nil then 
						Sound(script.Parent.Essentials, Settings.Sounds.Collect)
						Stats.Value = Stats.Value + Money.Value
						Money.Value = 0
						wait(1)
						script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Sea green")
						deb = false
						end
					end
				end
			end
		elseif Stealing.Stealing then -- if player isn't owner and stealing is on
			if CanSteal == true then
				CanSteal = false
				delay(Stealing.PlayerProtection, function()
					CanSteal = true
				end)
				if hit.Parent:FindFirstChild("Humanoid") then
					if hit.Parent.Humanoid.Health > 0 then
						local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
						if Stats ~= nil then
							local Difference = math.floor(Money.Value * Stealing.StealPrecent)
							Sound(script.Parent.Essentials, Settings.Sounds.Collect)
							Stats.Value = Stats.Value + Difference
							Money.Value = Money.Value - Difference
						end
					end
				end
			else
				Sound(script.Parent.Essentials, Settings.Sounds.Error)
			end
		end
	end
end)

script.Parent:WaitForChild("Buttons")
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
	spawn(function()
	if v:FindFirstChild("Head") then
		
		local ThingMade = script.Parent.Purchases:WaitForChild(v.Object.Value)
		if ThingMade ~= nil then
			Objects[ThingMade.Name] = ThingMade:Clone()
			ThingMade:Destroy()
		else
			--//Button doesn't have object, remove it
			error('Object missing for button: '..v.Name..', button has been removed')
			v.Head.CanCollide = false
			v.Head.Transparency = 1
		end
								
		if v:FindFirstChild("Dependency") then --// if button needs something unlocked before it pops up
			v.Head.CanCollide = false
			v.Head.Transparency = 1
			coroutine.resume(coroutine.create(function()
				if script.Parent.PurchasedObjects:WaitForChild(v.Dependency.Value) then
					if Settings['ButtonsFadeIn'] then
						for i=1,20 do
							wait(Settings['FadeInTime']/20)
							v.Head.Transparency = v.Head.Transparency - 0.05
						end
					end
					v.Head.CanCollide = true
					v.Head.Transparency = 0
				end
			end))
		end
		
		v.Head.Touched:connect(function(hit)
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if v.Head.CanCollide == true then
				if player ~= nil then
					if script.Parent.Owner.Value == player then
						if hit.Parent:FindFirstChild("Humanoid") then
							if hit.Parent.Humanoid.Health > 0 then
								local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
								if PlayerStats ~= nil then
									if (v:FindFirstChild('Gamepass')) and (v.Gamepass.Value >= 1) then
										if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,v.Gamepass.Value) then
											Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
										else
											game:GetService('MarketplaceService'):PromptPurchase(player,v.Gamepass.Value)
										end
									elseif (v:FindFirstChild('DevProduct')) and (v.DevProduct.Value >= 1) then
										game:GetService('MarketplaceService'):PromptProductPurchase(player,v.DevProduct.Value)
									elseif PlayerStats.Value >= v.Price.Value then
										Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
										Sound(v, Settings.Sounds.Purchase)
									else
										Sound(v, Settings.Sounds.ErrorBuy)
									end
								end
							end
						end
					end
				end
			end
		end)
		end
	end)
end

function Purchase(tbl)
	local cost = tbl[1]
	local item = tbl[2]
	local stats = tbl[3]
	stats.Value = stats.Value - cost
	Objects[item.Object.Value].Parent = script.Parent.PurchasedObjects
	if Settings['ButtonsFadeOut'] then
		item.Head.CanCollide = false
		coroutine.resume(coroutine.create(function()
			for i=1,20 do
				wait(Settings['FadeOutTime']/20)
				item.Head.Transparency = item.Head.Transparency + 0.05
			end
		end))
	else
		item.Head.CanCollide = false
		item.Head.Transparency = 1
	end
end

function Create(tab)
	local x = Instance.new('Model')
	Instance.new('NumberValue',x).Value = tab[1]
	x.Value.Name = "Cost"
	Instance.new('ObjectValue',x).Value = tab[2]
	x.Value.Name = "Button"
	local Obj = Instance.new('ObjectValue',x)
	Obj.Name = "Stats"
	Obj.Value = tab[3]
	x.Parent = script.Parent.BuyObject
end

--// This was very rushed and is inefficent; if you plan on making something like this don't use a child added listener.
script.Parent:WaitForChild('BuyObject').ChildAdded:connect(function(child)
	local tab = {}
	tab[1] = child.Cost.Value
	tab[2] = child.Button.Value
	tab[3] = child.Stats.Value
	Purchase(tab)
	wait(10)
	child:Destroy()
end)

1 comment

0

easy

Easy,

First you'd need to lay a block down, usually making this block the same size of a user so that when they step onto it it can fit. Then you would need to insert 'Script' inside the block so that this functions and it can add money. Group the part and name the group how much money you would want it to give. For example, "5000 Cash", so that you remember on how much cash you want the script to give. Name the part that is inside the group 'Head' as this is the leading script that it will be giving. Insert a script and ForceField inside of what you named 'Head'.

Insert this script inside of the script:

local ting = 0

function onTouched(hit)

if ting == 0 then 
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")

if check ~= nil then 

	local user = game.Players:GetPlayerFromCharacter(hit.Parent)
	local stats = user:findFirstChild("leaderstats")

	if stats ~= nil then 
		local cash = stats:findFirstChild("Cash")---Verander dit naar de naam dat ie moet geven Bijv: Leaderboard die naam is Cash Maak Dat <<<<< Dan Cash !!!!
		cash.Value  = cash.Value  +500 --  Verander 1000 in wat je wil
	wait(5) --Verander De 0.1 in wat jij wil hoelang the knop onbruikbaar is
	end 

end 

ting = 0
end 

end

script.Parent.Touched:connect(onTouched)

Insert 'Humanoid' inside of what is grouped so that the script can detect the users Humanoid and give the amount of money you desire it to give. And your all done! I hope this helped you, as there is not many tutorials on this. I may post a tutorial on Youtube on how this works and how to make it so that you can understand better on how to do this.

2 comments

0

He asked for the complete opposite try to read the question next time before answering.

0

I HATE THIS AWNSER!

This discussion is preserved as it was. New answers, comments, and votes are closed.