#Issue with Transparency and wait time

13 messages · Page 1 of 1 (latest)

quick belfry
#

Basically I'm making a dash where you go invisible and your walk speed increases briefly when you press Q, I got the part where you go invisible but when I try to make the character reappear it only does 1 body part at a time and it makes 1 body part appear for the wait time (Example: 2s), I am new to scripting so this is a big thud for me and I don't know where to start to resolve this issue and cant find anything about it on forums.

``Lua
local Uis = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character

Uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Q then else return end
for i,v in pairs(Player.Character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
v.Transparency = 1
end
end
end)

Uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Q then else return end
for i,v in pairs(Player.Character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
wait(2)
v.Transparency = 0
Player.Character:WaitForChild("HumanoidRootPart").Transparency = 1
end
end
end)
``

quick belfry
#

but then they reappear instantly

#

I want them to stay transparent for 3 seconds

#

or 2

dense plank
#

use a spawn function

#

or task.delay

#
Uis.InputBegan:Connect(function(key)
  if key.KeyCode == Enum.KeyCode.Q then else return end
    for i,v in pairs(Player.Character:GetDescendants()) do
      if v:IsA("BasePart") or v:IsA("Decal") then
        task.delay(2,function()
           v.Transparency = 0
          Player.Character:WaitForChild("HumanoidRootPart").Transparency = 1
        end)
      end
    end
end)
#

that way it doesnt yield the entire script

quick belfry
#

tysm

wary juniperBOT
#

studio** You are now Level 1! **studio

tepid lark
#

can you help me