Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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)
0
please put everything in a code bock not just that section YellowoTide 1992 — 9y
0
Also, findFirstChild() is deprecated use FindFirstChild() YellowoTide 1992 — 9y

1 answer

Log in to vote
0
Answered by
Wizzy011 245 Moderation Voter
9 years ago

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!

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

Answer this question