here is my code, I get no errors in output.
local touched = false local function onTouch(hit) end workspace.indicator1.Touched:Connect(onTouch) local function onTouch(hit) if (touched == false) then touched = true if game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled ~= true then if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true setText("Hello!") end end end end workspace.indicator1.Touched:Connect(onTouch)
I really don't know why it wouldn't work, but basically I am trying to make it so when you touch the block, the gui shows and the text of the gui changes to "Hello!" then the gui will disappear (didn't add that yet!) and when you touch the block again, the gui won't come up and nothing will happen. I only want it to occur once. any help will be appreciated I have been trying to figure it out for days now, and I am new to coding so sorry if this is a dumb question thank you!
local touched = false local function onTouch(hit) if (touched == false) then --touched = true --this doesnt check if touched is a humanoid or not, therefore not letting an actual humanoid interact with it if game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled ~= true then if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true touched = true setText("Hello!") delay(3, function() touched = false end) end end end end workspace.indicator1.Touched:Connect(onTouch)
I think thats whats wrong. Also, why are there 2 functions of the same name? Edit: I fixed the script. It missed a ")" next to delay(3,function().