Part button that shows a GUI only work once

I made a part that shows a gui to the player when its clicked, it only work once for no reason, I tried putting a print in the code and it did print it, this got me all confused, heres my script

script.Parent.MouseClick:Connect(function(plr)
	if not plr:WaitForChild("Inventory"):FindFirstChild("Wallet") then --the model is not in place
		print("lol")
		plr:WaitForChild("PlayerGui").inGame.Swiper.Visible = true
	elseif plr:WaitForChild("Inventory"):FindFirstChild("Wallet") then --the model is in place and it enables the gui that needed so it will function
		print("LOL")
		plr:WaitForChild("PlayerGui").inGame.Swiper.Visible = true
		plr:WaitForChild("PlayerGui").inGame.Swiper.Card.Visible = true
		plr:WaitForChild("PlayerGui").inGame.Swiper.Arrow.Visible = true
	end
end)
2 Likes

First: The Code is written so badly its extremely hard to read. You HAVE to organise your Code better.

Second: Can you send the Explorer pictures?

1 Like

Translated to your language is

script.Parent.MouseClick:Connect(function(Player) -- dude clicks
	if not Player:WaitForChild("Inventory"):FindFirstChild("Wallet") then --  Player guy has no wallet
		print("lol") -- no wallet
	else
		print("LOL") -- has wallet
	end
end)
1 Like

ok i fixed your script

script.Parent.MouseClick:Connect(function(Player)
	if Player:FindFirstChild("Inventory") and Player.Folder:FindFirstChild("Wallet") then
		Player:WaitForChild("PlayerGui").inGame.Swiper.Visible = true
		Player:WaitForChild("PlayerGui").inGame.Swiper.Card.Visible = true
		Player:WaitForChild("PlayerGui").inGame.Swiper.Arrow.Visible = true
	else
		warn("no.")
	end
end)
1 Like

on the output it says

> no. (x1266)

its works more than 1 times

1 Like

nvm, I saw this post so I tried using remote event and it worked, sorry if my script is messy