GUI Scripting Problem

GUI Script Does Not Work

I have this script so that when you step on a part in the workspace it will open the GUI. The problem is that when someone steps on the part it opens for the entire server. I have made it so it is a local script inside of Starter GUI, but it is not inside of any GUIs it is just by itself in the Starter GUI. Please help. :confused:

game.Workspace.ShopButton.Touched:Connect(function(hit)
	if hit then
		script.Parent.ShopGUI.Frame.Visible = true
	end
end)

then make the script inside of the ui?

1 Like

i have an idea

make the script inside of the “ShopButton” then do

(the touched event)
player.PlayerGui.ShopGUI.Frame.Visible = true

1 Like

I will try that right now. I hope it works.

1 Like

game.Workspace.ShopButton.Touched:Connect(function(hit)
if hit.Name == “Torso” then
script.Parent.ShopGUI.Frame.Visible = true
end
end)

1 Like

yeah something along the lines of that

1 Like

or
local Activated = false
game.Workspace.ShopButton.Touched:Connect(function(hit)
if hit.Name == “Left Leg” or hit.Name == “Right Leg” and Activated == false then
Activated = true
script.Parent.ShopGUI.Frame.Visible = true
end
end)
while true do
if script.Parent.ShopGUI.Frame.Visible == false then
Activated = false
end
end

1 Like

We are testing the first script right now.

1 Like

Remember to put the “while true do” at the end of the script

1 Like

I dont think place it in a while loop is necessary. I believe the first edit is better.

1 Like

No, it is not necessary but I do not know how the rest of the script works

1 Like
	game.Players.GetPlayerFromCharacter(hit.Parent)
		if hit.Parent then
                 script.Parent.ShopGUI.Frame.Visible = true
else 
print("Not avaible")
	end
end)
1 Like

try placing this into starter player or characterscripts

1 Like

this are all bad methods this is the fault

GUI.Visible = true

instead of setting it to false or true
here is the correct one

GUI.Visible = not GUI.Visible

the while loop method is bad just use an event

1 Like

Ok I am working on it! So far the top 2 do not work.

1 Like

I forgot the wait() xD (30 caracteres and my english is so bad im speak spanish)

1 Like

so its a touched event?

here is an example of it

script.Parent.Touched:Connect(function(hit)
    -- player
    local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if Player then
        -- gui stuff
        local PlayerGui = Player.PlayerGui
        if PlayerGui then
            -- make it visible
            local Gui = GUI_PATH_HERE
            Gui.Enabled = not Gui.Enabled
        end
    end
end)
1 Like

So here is the script we have right now:

script.Parent.Touched:Connect(function(hit)
– player
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
– gui stuff
local PlayerGui = Player.PlayerGui
if PlayerGui then
– make it visible
local Gui = script.Parent.ShopGUI.Frame
Gui.Enabled = not Gui.Enabled
end
end
end)

We have it placed inside of the starter GUI. It does not work.

1 Like

Why is it bad practice to use booleans? :thinking:

1 Like

well its not if you want it not visible if you touch it again

1 Like