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

This transparency loop should take 0.1 transparency every 0.5 seconds, but it won't?

Asked by 4 years ago
Edited 4 years ago

This script should minus the parts inside the model's transparency by 0.1 every half a second after a button is clicked, but it only changes the transparency of 1 part.

Script:

local model = workspace.model1:GetChildren()
local button = workspace.button1.ClickDetector

button.MouseClick:Connect(function(onclicked)

for i,v in pairs(model) do
    repeat
        v.Transparency = v.Transparency - 0.1
        wait(0.5)
    until v.Transparency == -0.1
end

end)
0
I dont know what you are using repeat for, but I always put the wait() right after "do" so it it immediately waits before proceeding. mantorok4866 201 — 4y
0
Code runs line by line which is why everything won't change at the same time. Your repeat until loop wont change all the bricks transparency's at the same time unless you use spawn or cooroutines. Also you might get issues with floating point numbers. Try instead: until v.Transparency <= -0.1. royaltoe 5144 — 4y
0
Your script will make one part at a time go transparent. Each part will take 5.5 seconds. Are you sure this is what you want? compUcomp 417 — 4y

1 answer

Log in to vote
1
Answered by
St_vnC 330 Moderation Voter
4 years ago
Ad

Answer this question