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

How could I set extra cash points to the tycoon cash and leaderboard im using?

I am using a tycoon leaderboard and a tycoon cash collector in my place. I am having trouble finding a script to add to a block that would allow me to gain extra cash when I step on the block. I tried a basic extra cash giving block. It did give me the extra cash but when I went to purchase an item in my tycoon, the extra cash did not work on the items. Also, If I would gain the extra cash from the extra cash block then go back to my tycoon and step on my tycoon cash collected block, the two values did not add together. The extra cash giver block was specific to add to the existing value of "cash". I am including the scrip im using for the tycoon purchase handler. Can any one help me come up with a extra cash script that I could place in a block and, would work with the linked leaderborad cash and the tycoons purchase handler?

----------------Purchase handler-------------

objects = {}
teamcolor = BrickColor.new(script.Parent.Name)
config = script.Parent.Parent.Parent.Configuration
wait(1)

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

script.Parent.Essentials.Collector.Touched:connect(function(hit)
	if hit:FindFirstChild("Cash") then
		script.Parent.Cash.Value = script.Parent.Cash.Value + hit.Cash.Value
		Instance.new("Sparkles",hit).Color=Color3.new(math.random(1,255)/255,math.random(1,255)/255,math.random(1,255)/255)
		game.Debris:AddItem(hit,0.1)
	end
end)


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
					local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
					if cashmoney ~= nil then 
						cashmoney.Value = cashmoney.Value + script.Parent.Cash.Value
						script.Parent.Cash.Value = 0
					end
				end
			end
		end
	end
end)

script.Parent:WaitForChild("Buttons")
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
	if v:FindFirstChild("Head") then
		
		local object = script.Parent.Purchases:FindFirstChild(v.Object.Value)
		if object ~= nil then
			objects[object.Name] = object:Clone()
			object:Destroy()
		else
			print("Button: "..v.Name.." is missing its object and has been removed.")
			v.Head.CanCollide = false
			v.Head.Transparency = 1
		end
								
		if v:FindFirstChild("Dependency") then
			v.Head.CanCollide = false
			v.Head.Transparency = 1
			coroutine.resume(coroutine.create(function()
				if script.Parent.PurchasedObjects:WaitForChild(v.Dependency.Value) then
					if config.ButtonFadeInDependency.Value == true then
						for i=1,20 do
							wait(config.ButtonFadeInTime.Value/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 cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
								if cashmoney ~= nil then
									if cashmoney.Value >= v.Price.Value then
										cashmoney.Value = cashmoney.Value - v.Price.Value
										objects[v.Object.Value].Parent = script.Parent.PurchasedObjects
										if config.ButtonExplodeOnBuy.Value == true then
											local explosion = Instance.new("Explosion",workspace)
											explosion.Position = v.Head.Position
											explosion.DestroyJointRadiusPercent = 0
											explosion.BlastPressure = 0
										end
										if config.ButtonFadeOutOnBuy.Value == true then
											v.Head.CanCollide = false
											coroutine.resume(coroutine.create(function()
												for i=1,20 do
													wait(config.ButtonFadeOutTime.Value/20)
													v.Head.Transparency = v.Head.Transparency + 0.05
												end
											end))
										else
											v.Head.CanCollide = false
											v.Head.Transparency = 1
										end
									end
								end
							end
						end
					end
				end
			end
		end)
		
	end
end

1 answer

✓ Accepted answer

Hello there, Brooksdart.


Typically simply adding to cash in the leaderboard would work, however this script takes extra measures to ensure safety, and ensure exploiters can't mess with their money as easily.


On line 73 we see;

local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)

##So what does this mean? ###This means that you need to change the cashmoney value, AND the leaderboard value.

We can do this by using a touch script, and finding the players MoneyStorage. Once you do that, you need to add to it.


###I will not be giving you the script, but I hope you understand enough to be able to play with it yourself.

1 comment

0

Im not exactly sure how I would go about that but I think I can use parts from the existing script to create one that should work. Thanks for the tip it really helped me understand where I was going wrong. ;)

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