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

Why isn't this one working either?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

function SAM(p) p.Transparency = 1 if p.Transparency == 1 then p.Transparency = 0 else p.Transparency = 1 end end

            script.Parent.Touched:connect(SAM)
 I wanna try to make the leg dissapear then reappear
0
Edit your post to fix the Lua formatting. BlueTaslem 18071 — 9y
0
What do you mean saulpj3 0 — 9y
0
Look at the post. There is syntax highlighting on the last sentence and only the last line of your code. Fix it, please, so we can read it reasonably. BlueTaslem 18071 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You did not make your script edited to look like a script but I'll still try. First, anything that touches the part will change. You have no waits and I believe everything is happening, but too fast to notice. Try this:

function SAM(p)
p.Transparency = 1
wait(1)
if p.Transparency == 1 then
p.Transparency = 0
end
end
script.Parent.Touched:connect(SAM)

Now, to make this not spam we use Debounce. One way to explain a Debounce is: A variable that will stop the script from being start again causing it to repeat. If you touch something, that will not count or be registered as one touch, it will be several. Here's the script with Debounce:

debounce = false -- This MUST be false or it will not allow anything to happen

function SAM(p)
    if debounce == false then -- if it's true, nothing will happen, only if debounce = false
        debounce = true -- Now this script cannot repeat when touched
        p.Transparency = 1
        wait(1)
        if p.Transparency == 1 then
            p.Transparency = 0
            wait(1) -- Waits 1 second before debounce = false
            debounce = false -- Now debounce is false; touching it again will work
        end
    end
end
script.Parent.Touched:connect(SAM)

Both should work. You will have to edit if you want more then one leg changing transparency.

Ad

Answer this question