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

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

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

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

3 comments

0

Yeah thanks it was fixed.

0

what fixed it?

0

just nvm atleast it is fixed

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

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