So im working on a game that invovles clicking to get cash in the game but i cant seem to figure out how to connect these scripts

wait()

function scan(p)
	for i=1,#p:children() do
		if p:children()[i]:IsA('BasePart') then
			if (p:children()[i].Size.x + p:children()[i].Size.y + p:children()[i].Size.z) < 25 then
				local c=Instance.new('ClickDetector', p:children()[i])
					c.MouseClick:connect(function()
						p.CanCollide = false
						p.Transparency = 1
	               				c:Destroy()
					end)
				end
			end
		scan(p:children()[i])
	end
end

And

scan(workspace)

script.Parent.MouseClick:Connect(function(player)
	if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Money") then
	        player.leaderstats.Money.Value = player.leaderstats.Money.Value + 500 -- add 1 to money.
	end
end)

can anyone help me figure out this issue Please and thank you

4 comments

0

Please make the code a codeblock.

0

Ok i did

0

So i'm not quite sure what it is that you're doing (or what the scan function is for) but...You should never allow players to edit their leaderstats via the client, nor do you want to store leaderstats on the client.

0