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

How do I make this when equipped it plays it but it doesn't repeat?

Alright, I'm making a simple transparency punch and this is what I have issues with

while true do
wait(.5)
script.Parent.Transparency = 0
	wait(0.2)
	script.Parent.Transparency = 0.5
	wait(0.2)
	script.Parent.Transparency = 0.5
	wait(0.5)
end

This is the repeat, this ruins what i'm trying to make and induces alot more work for me to do for no reason.

This is my non-repeat script, works well and fine but it doesn't do transparency ever again, like EVER.

wait(.5)
script.Parent.Transparency = 0
	wait(0.2)
	script.Parent.Transparency = 0.5
	wait(0.2)
	script.Parent.Transparency = 0.5
	wait(0.5)

Is there any way to fix?

1 comment

0

I don't understand what are you trying to accomplish. The first code is an infinite loop, the second one is not a loop. If you want your code to repeat itself, stick to your first one.

1 answer

Use Tool.Equipped to achieve the effect you want, assuming you're equipping a tool.

Sample (local inside tool):

local tool = script.Parent

tool.Equipped:Connect(function()
    -- the code inside here will run whenever the player equips the tool, shocking.
    print("i've been equipped!")
end)

1 comment

0

it says equipped isn't a valid member of part

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