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

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

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)

1 comment

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?

1 answer

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)

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