Hello, I am new to roblox scripting and I need help.
local Gui2 = script.Parent.Parent.Value.Value
script.Parent.ClickDetector.MouseClick:Connect(function (player)
print(“worked”)
if player.PlayerGui.Gui2.Enabled == true then
player.PlayerGui.Gui2.Enabled = false
else
player.PlayerGui.Gui2.Enabled = true
end
end)
In the code above, I am trying to make it so I can type a name into the Intvalue, so I dont have to type Gui and then the number everytime. Whats happening is I dont know how to implement the variable above into the line of code. Im not sure if that makes since, but if anyone can help it would make my day.
local Guiname = script.Parent.Parent.Value.Value
script.Parent.ClickDetector.MouseClick:Connect(function (player)
print("worked")
local v = player.PlayerGui.Guiname
if v.Enabled == true then
v.Enabled = false
else
v.Enabled = true
end
end)
or you need like search for gui that named same as the value?
if so, then
local Guiname = script.Parent.Parent.Value.Value
script.Parent.ClickDetector.MouseClick:Connect(function (player)
print("worked")
local v = player.PlayerGui[Guiname] -- this
if v.Enabled == true then
v.Enabled = false
else
v.Enabled = true
end
end)
local Guiname = script.Parent.Parent.Value.Value
script.Parent.ClickDetector.MouseClick:Connect(function (player)
print("worked")
local v = player.PlayerGui:FindFirstChild(Guiname) -- this
if v then -- if exist
if v.Enabled == true then
v.Enabled = false
else
v.Enabled = true
end
end
end)