OnTouched Event not working

I’m going to try it in studio and see if I can get the same problem

Same error. 30charssssssssssssssssssssssss

Can you screenshot the output?

There should be no errors at line 4.


Here. 30charsssssssssssssssssssssssssss

local Part = script.Parent

Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit)
if plr then
local playergui = plr:WaitForChild(“PlayerGui”)
local Quest1 = plr.PlayerGui.Quest1
print(“working”)
Part.BillboardGui.arrow_downward.Visible = false
Part.BillboardGui.done.Visible = true
Quest1.Frame:Destroy()
Quest1.QuestFinished.Visible = true
end
end
end)

Try this

I think the problem is very obvious. You’re :remove()ing Quest1 before changing the QuestFinished value. Why are you removing Quest1 anyways if you still want the QuestFinished value to be around?

There is not errors, but the “print” thing doesn’t print in the output and nothing happens.

Basicly they are like this: image

1 Like

They are removing the frame not the gui I think

1 Like

Sorry I didn’t read quite carefully, what’s the problem you’re having exactly? Any errors? You were also editing the UI in StarterGui and not PlayerGui.

As well, it’s generally useless to use global variables (variables not prefixed with local), and don’t use :remove(), use :Destroy() instead.

1 Like

I think I know why!

local Part = script.Parent

Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local playergui = plr:WaitForChild(“PlayerGui”)
local Quest1 = plr.PlayerGui.Quest1
print(“working”)
Part.BillboardGui.arrow_downward.Visible = false
Part.BillboardGui.done.Visible = true
Quest1.Frame:Destroy()
Quest1.QuestFinished.Visible = true
end
end
end)

when getting the plr put hit.Parent instead of hit

1 Like

Thanks! It works!!
It was very long and painfull. Have a great day/night.

Thank you! I can’t believe I missed it, that always happens to me haha

Also, don’t forget to use the good brakets !

1 Like