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

I want to make a button that you can click on, instead of touching it, any ideas plz?

Basically, I want to make a tycoon that you can buy stuff on it while clicking the button, instead of touching it. Please if you know how to do that, can you help me? I tried a lot of different things but it didn't work sadly. Please, can you take tycoon from "Zednov's Tycoon Kit" on free models? I think this should be the script for touching a button:

	
	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
	

5 comments

0

What are you even trying to do?

0

use a ClickDetector

0

Yea I know that I need to use click detector, but it didn't work just like that. Try getting the model yourself and making clickdetector. I tryed multiple things but it didn't work D:

0

Uhm, can you elaborate? I didn't quite understand what you said.

0

So I took "Zednov's Tycoon Kit" on free models. You know how tycoon works, you touch a button and then you buy something? But I wanted to make it so you can click a button and then you will buy something. So you don't have to touch it to buy it. I looked at scripts in game and I tried everything but I couldn't make it so I can make a click a detector to buy it when clicked instead touching it.

2 answers

Make a click detector under the button and call it as such

ClickDetector.MouseClick:Connect(function(plr)
	print(plr.Name)
end)

When you click the part with the click detector under it, it should print your name.

1 comment

0

Yea I know that, but now how do you make is so this script works? I tried making clickdetector and I called that function instead of touched function but it didn't work

Nevermind I added whole another function and make something, and now it works. Thank you for trying anyway. :D

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