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

How can i make this Model Unclickable?

I currently have a model which when clicked on gives you 30 money in your player stats how can i make it so that after being clicked and having earnt the money, you are not able to click it again?

I have a Click Detector inside my model And here is the script:

function OnClick()

	local players = game.Players:GetPlayers()
	for i=1,#players do
		if (players[i]:FindFirstChild("leaderstats") ~= nil) then
			local clicks = players[i]:FindFirstChild("leaderstats")["Money"]
			if (clicks ~= nil) then
				clicks.Value = clicks.Value + 30
			end
		end
	end

	local f = Instance.new("Fire")
	f.Parent = script.Parent.Head
	game.Debris:AddItem(f, .2)

end

script.Parent.ClickDetector.MouseClick:connect(OnClick)

"If anyone can help me make it so that you can only click the model once It would be greatly appreciated"

1 comment

0

I think you might be able to disable the click detector or script after you clicked on it?

2 answers

Use a variable, use the following script.

local used = false

function OnClick()
 	if used == false then
		local players = game.Players:GetPlayers()
		for i=1,#players do
			if (players[i]:FindFirstChild("leaderstats") ~= nil) then
				local clicks = players[i]:FindFirstChild("leaderstats")["Money"]
				if (clicks ~= nil) then
					clicks.Value = clicks.Value + 30
					used = true
				end
			end
		end
	
		local f = Instance.new("Fire")
		f.Parent = script.Parent.Head
		game.Debris:AddItem(f, .2)	
	end 
end

script.Parent.ClickDetector.MouseClick:connect(OnClick)

1 comment

0

Do i add this in a seperate script?

You could create a variable and set it to false then check if the variable is false. If that variable is false then do what you want and set the variable true If the variable is true or anything but false do nothing.

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