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

Why does my script only run twice, but no more times?

Asked by
Faazo 84
6 years ago

I have this script that opens a ScreenGui when the detector is touched. It works perfectly the first two times, but the thing is that after two times of opening and closing it doesn't work anymore. Here is my script

    Players = game:GetService("Players")
    LocalPlayer = Players.LocalPlayer
    PlayerGui = LocalPlayer.PlayerGui
    Detector = game.Workspace.RoomDetector1
    RS = game:GetService("ReplicatedStorage")

ShopOpen = false

Detector.Touched:Connect(function(touch)    
    if ShopOpen == false and touch.Parent.Name==LocalPlayer.Name then
    RS.Rooms:Clone().Parent = PlayerGui  
    ShopOpen=true
    end
end)

game.Players.LocalPlayer.PlayerGui:WaitForChild("Rooms").Frame.Close.MouseButton1Click:Connect(function()
    ShopOpen = false   
    print ("Test")
end)

I also noticed that it only prints test once. This is really weird. Help is appreciated.

0
Add a wait and how long you want it to stay open, then add when will it close, which is wakt Carforlife1 59 — 6y
0
I already have a closing script in my close button. That isn't the problem. Faazo 84 — 6y

Answer this question