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

For Some Reason this script only works once this is very confusing?

Asked by 1 year ago

For Some Reason this script only works once, please someone help me this is very urgent

local touchPart = script.Parent

touchPart.Touched:Connect(function(part)
    local player = game.Players:GetPlayerFromCharacter(part.Parent)

            if player then
                player.PlayerGui:WaitForChild("DoubleJumpShop").Frame.Visible = true

        end

end)
0
What are you trying to do exactly? The script works fine. Are you trying to "close" the Frame when the player stop touching the part? CMVProduction 25 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

I assume you're trying to close the GUI when the player leaves the part. Use the .TouchEnded event which is the complete opposite of the .Touched event.

local touchPart = script.Parent

touchPart.Touched:Connect(function(part)
    local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)

    if player then
        player:WaitForChild("PlayerGui"):WaitForChild("DoubleJumpShop").Frame.Visible = true
    end
end)
touchPart.TouchEnded:Connect(function(part)
    local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)

    if player then
        player:WaitForChild("PlayerGui"):WaitForChild("DoubleJumpShop").Frame.Visible = false
    end
end)
Ad

Answer this question