The script for tycoon doesn't work

I saw the script on the Internet and decided to try it, but I didn’t succeed(

local players = game:GetService("Players")
local purchosedSpawn = workspace.AutoDropper --We indicate the dropper
local button = script.Parent --Button for buy dropper
local spawner = purchosedSpawn.DropperPart 
local pricePart = button.Price.PriceGui.PriceValue --Indicate gui
local priceGui =  button.Price.PriceGui.PriceText --Indicate text
local scriptDrop = spawner.Dropper2BlockScript --I IDK what it is for
priceGui.Text = "Buy Dropper - $"..pricePart.Value

local function onHit(hit)
	local tycoon = workspace.Tycoon
	local player = players:GetPlayerFromCharacter(hit.Parent)
	if not player then return end
	if tycoon.Owner.Value == player then
		if player.leaderstats.Money.Value >= pricePart then
			player.leaderstats.Money.Value -= pricePart
			for _, Child in 
				ipairs(purchosedSpawn:GetChildren())do
				if Child:IsA("Part") then
					Child.Transparency = 0
					Child.CanCollide = true
					spawner.Transparency = 0.45
					script.Disabled = false
					purchosedSpawn:Destroy()
				end
			end
		end
	end
end
button.Touched:Connect(onHit())

But I got a mistake somewhere. I do not know how to fix it.


Sorry for my English, it’s very bad.
Youtube link

It has to be button.Touched:Connect(onHit)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.