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

I made a script so that if I touch a circle it enables a GUI but it doesnt enable again?

Asked by 4 years ago
Edited 4 years ago

So I was making a trader to sell Swords and I made a gui for it which the gui has a script where if you touch a circle in the map it makes the gui visible which works then later I made a button so it would close the gui but when you press it it works but later when you try to open the gui again using the button it doesnt work here are the codes I dont know how to fix this could anybody show me what is wrong or tell me how to fix it.

--- This is the Button For it to close.
function click()
    if script.Parent.Parent.Visible == true then
    script.Parent.Parent.Visible = false
    else script.Parent.Parent.Visible = true
    end
end

script.Parent.MouseButton1Click:connect(click)

-

-

---- Touch Script For the Circle Object
function touch(hit)
    if game.Players:findFirstChild(hit.Parent.Name) ~= nil then
        local player = game.Players[hit.Parent.Name]
        if player.PlayerGui:findFirstChild("Info") == nil then
            local gui = script.Info:clone()
            gui.Parent = player.PlayerGui
            repeat
                wait()
            until (player.Character.Torso.Position - script.Parent.Position).magnitude > 5
            gui:remove()
        end
    end
end

script.Parent.Touched:connect(touch)

2 answers

Log in to vote
0
Answered by
WN0820 11
4 years ago

I would recommend making an folder in Workspace and name it Shops and then put in a part what ever name you like for it. Then if you have a screengui where you would like to sell the swords put a localscript inside it and put in this script while wait() do wait(0.1) local mag = (workspace.Shops.Nameofyourpart.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude if mag <= 6 then script.Parent.Shop.Visible = true else script.Parent.Shop.Visible = false end endand then rename the stuff when you go off the part it closes I think use it or not

0
Yeah thanks it was fixed. RealMade123 0 — 4y
0
what fixed it? WN0820 11 — 4y
0
just nvm atleast it is fixed WN0820 11 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

It was fixed so we had to make remote events and change the clone script .

Answer this question