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

Is there a method to add an wait() onto an if and then as a single function? [closed]

Asked by 9 years ago

For example

if HumanoidIsFound and PlayerIsFound then

I am having troubles understanding the if and then concepts using an wait(). I have read wiki articles as well as Roblox Blogs on the If and then and wait, although I still can not understand how to place all three together in a single function.

The line im working with---

if HumanoidIsFound and PlayerIsFound then
        PlayerIsFound.PlayerGui.ScreenGui.TextButton.Visible = true
    end
end

If necessary to understand what I mean here is the script im working with------

local p = script.Parent


function onTouch(part)
    local HumanoidIsFound = part.Parent:FindFirstChild("Humanoid")
    local PlayerIsFound = game.Players:GetPlayerFromCharacter(part.Parent)
    if HumanoidIsFound and PlayerIsFound then
        PlayerIsFound.PlayerGui.ScreenGui.TextButton.Visible = true
    end
end

p.Touched:connect(onTouch)

Locked by BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 9 years ago

Never mind I Figured it out lol... Im dumb.

local p = script.Parent


function onTouch(part)
    local HumanoidIsFound = part.Parent:FindFirstChild("Humanoid")
    local PlayerIsFound = game.Players:GetPlayerFromCharacter(part.Parent)
    if HumanoidIsFound and PlayerIsFound then
        PlayerIsFound.PlayerGui.ScreenGui.TextButton.Visible = true
        wait(3)
        PlayerIsFound.PlayerGui.ScreenGui.TextButton.Visible = false
    end
end

p.Touched:connect(onTouch)

0
Lol. yumtaste 476 — 9y
Ad