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

Open a GUI While standing on part?

Asked by 5 years ago

Hi! I am attempting to make a working walk-in-wardrobe, where when you walk in, and touch the part, it will open the GUI, Then when you walk out, it detects that, and closes the gui. So the GUI is open on a while loop, Similar to this psuedo code:

part = Script.Parent
gui = player.PlayerGui.ClothesGui.MainFrame
while player touching part:
gui.visible = True
else
gui.visible = False

Any help appreciated, Many Thanks, Mineblocks47

0
If you don't have experience with Lua then there's no point in helping you giving you free code. Learn by starting at developer.roblox.com xPolarium 1388 — 5y
0
lol HaveASip 494 — 5y
0
Use Touched and TouchEnded events HaveASip 494 — 5y
0
GUI wont really work with touching a brick that easily.. you need to use Remote Events. HeyItzDanniee 252 — 5y

2 answers

Log in to vote
2
Answered by
Voxozor 162
5 years ago

Hello! First: you need to insert Script in the part and place this:

local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = game.Workspace
RemoteEvent.Name = "ClothesEvent"

function onTouched(hit)
    local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
    RemoteEvent:FireClient(Player)
end

script.Parent.Touched:Connect(onTouched)

Second: Insert LocalScript in MainFrame and place this:

game.Workspace:WaitForChild("ClothesEvent")
local debounce = false

game.Workspace.ClothesEvent.OnClientEvent:Connect(function ()
    if debounce == false then
        script.Parent.Visible = true
        debounce = true
    end
end)

Also if you want to close the shop you should to insert TextButton in MainFrame and insert LocalScript and place this:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
end)

I hope that helps you. Good luck.

Ad
Log in to vote
0
Answered by
fr2013 88
5 years ago

If you want a TweenPosition, then I got one for you. First insert a normal Script inside of the part you want to touch. Then put the ScreenGUI inside of the script and name it for example "Shop" in your script. (If you want to change the name of your ScreenGUI, then also change it in the script that ahs the name Shop) And then once you put it all in it should look like this: Part > Script > Shop

Here's the script:

local Delay = 1 -- Time it takes to scroll down / up

function onTouch(hit)

    if game.Players:FindFirstChild(hit.Parent.Name) then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if not player.PlayerGui:FindFirstChild("Shop") then
            local gui = script.Shop:Clone()
            gui.Parent = player.PlayerGui

            gui.Frame:TweenPosition(UDim2.new(.5,0,.5,0),"Out","Quad",Delay,true)
            repeat wait() until (player.Character.HumanoidRootPart.Position - script.Parent.Position).magnitude > 5

            gui.Frame:TweenPosition(UDim2.new(.5,0,-.5,0),"Out","Quad",Delay,true)
            wait(Delay)
            gui:Remove()
        end
    end

end

script.Parent.Touched:Connect(onTouch)

Answer this question