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

Making a GUI visible/invisible with a script not working? [SOLVED, THANKS FOR THE HELP]

Asked by 9 years ago

I have attempted to script an onTouch function of sorts that SHOULD make certain text labels in the GUI be visible at certain times. This does not seem to be working. I do not see any errors in the output or developer console, so I have no idea what is wrong with it.

local gui1 = game.StarterGui.Gui1.Frame
function doSomethingOnTouch(part)
local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil then
gui1.label1.Visible = true
wait(3)
gui1.label1.Visible = false
wait()
gui1.label2.Visible = true
wait(3)
gui1.label2.Visible = false
end
end

script.Parent.Touched:connect(doSomethingOnTouch)
0
easy fix. You need to change the players gui not that gui. Thetacah 712 — 9y
0
I made a typo, sorry. It should work now! Thetacah 712 — 9y

3 answers

Log in to vote
1
Answered by
Thetacah 712 Moderation Voter
9 years ago

Sorry for the lack of explaining here, I don't have much time/

I don't have much time to explain, but I basically checked if the thing that touched it was a player by using the GetPlayerFromCharacter method.

After that, I made the gui1 variable which will actually change Visibility since it's the gui in the players playergui itself. That's pretty much all that needed to be done.


function ontouched(part) local hum = part.Parent:FindFirstChild("Humanoid") if hum and game.Players:GetPlayerFromCharacter(part.Parent) and hum.Health >0 then local gui1 = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("PlayerGui"):WaitForChild("Gui1"):WaitForChild("Frame") gui1.label1.Visible = true wait(3) gui1.label1.Visible = false wait() gui1.label2.Visible = true wait(3) gui1.label2.Visible = false end end script.Parent.Touched:connect(ontouched)
Ad
Log in to vote
0
Answered by 9 years ago

lol and spikey you can do this

local Gui = script.Parent local Button = script.Parent.TextButton local Frame = script.Parent.Frame Open = false

MouseButton1Down:connect(function(Open)

if (Open == false) then do Open = true Button.Text = "Close" Frame.Visible = true

elseif (Open == true) then do Open = false Button.Text = "Open" Frame.Visible = false
Log in to vote
-4
Answered by 9 years ago

I'm not sure,try this though,

Make a ScreenGui with a Frame and Button and Local Script

The Button is what will Open/Close the gui The Frame is what will Open/Close

local Gui = script.Parent local Button = script.Parent.TextButton local Frame = script.Parent.Frame Open = false

MouseButton1Down:connect(function(Open)

if (Open == false) then do Open = true Button.Text = "Close" Frame.Visible = true

elseif (Open == true) then do Open = false Button.Text = "Open" Frame.Visible = false

0
@Spikey, that's not what I'm aiming for. I want a message to appear when you touch a brick in a certain part in the game. dirty_catheter 7 — 9y

Answer this question