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

How would the modified regen script look if you converted it into a click regen?

Sorry, I had posted a question similar to this and did what the answer pertained yet it still didn't change this touch regen into a click regen. Yes I did add a click detector.

local box = script.Parent


local debounce = false

local everything = {model}
local names = {model}

local children = game.Lighting:children()
for i=1,#children do
	if (children[i].Name == "Tech") then 
		table.insert(everything, children[i]:clone())
		table.insert(names, children[i].Name)
	end
end


function regen()
	for i=1,#everything do
		game.Lighting:findFirstChild(names[i]):clone() 
		new_thing = everything[i]:clone()
		new_thing.Parent = game.Workspace
		new_thing:makeJoints()
	end
end

function onTouched(hit)
	local humanoid = hit.Parent:findFirstChild("Humanoid") 
	if humanoid~=nil and debounce == false then
		debounce = true
		
		script.Parent.BrickColor = BrickColor.new(1020)

		regen()
		wait(102)


		script.Parent.BrickColor = BrickColor.new(1020)


		debounce = false
	end
end


script.Parent.Touched:connect(onTouched)

2 comments

0

please put everything in a code bock not just that section

0

Also, findFirstChild() is deprecated use FindFirstChild()

1 answer

After you've placed a clickdector in the parent of the script (if the parent is a brick), you'd just have to change.Touched to .ClickDetector.MouseClick on the very last line. If you really wanted, you could rename the function of onTouched, but this isn't a requirement.

You'd also need to remove line 28 as there's no humanoid anymore, as well as the humanoid~=nil and from line 29.

Then you're all set!

1 comment

0

No, it didn't seem to work, by deleting lines 28 and 29. I also changed the last line like you said also.

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