OnTouched Event not working

  1. What do you want to achieve? I made a Quest system and I made it so if you touch a certain part the Quest gets finished but nothing happens.

  2. What is the issue? Everytime I try to touch the final Part, nothing runs. It is on a local script.

  3. What solutions have you tried so far? I’ve tried making it a normal script but it would execute on the whole server. I also tried to change the “Part = script.Parent” to “local Part = script.Parent”

Here is my script.

Part = script.Parent
Quest1 = game.StarterGui.Quest1

Part.Touched:Connect(function()
	print("working")
	Part.BillboardGui.arrow_downward.Visible = false
	Part.BillboardGui.done.Visible = true
	Quest1.Frame:remove()
	Quest1.QuestFinished.Visible = true
end)
1 Like

LocalScripts don’t run in Workspace unless parented to your Character

Also, changing stuff in StarterGui won’t affect what the player sees, because what they see is stored in game.Players.LocalPlayer.PlayerGui, which is where stuff in StarterGui gets copied to
.

1 Like

Well it still doesn’t print the “(print(“working”)”

1 Like

They do run in workspace. 30charssssss

1 Like

You could try using a server script. Just add a part in the script that checks exactly which player has touched the part and then set the game up accordingly. I’m kinda guessing here since I do not really do super advanced scripting.

1 Like

First of all replace the local script with a regular script then write in it:

local Part = script.Parent

Part.Touched:Connect(function(hit)
    if hit.Parent.humanoid then
    local plr = game.Players:GetPlayerFromCharacter(hit)
    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)

Maybe this works?
If it doesn’t tell me what errors show up in output.

2 Likes

It says: humanoid is not a valid member of Model

1 Like

Make sure the Humanoid has a capital h.

well, now it says: Workspace.Quest1_Part.Script:6: attempt to index nil with ‘PlayerGui’

do
local Part = script.Parent

Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit)
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)

1 Like

It gives an erorr. Workspace.Quest1_Part.Script:7: Unexpected Unicode character: U+201c. Did you mean ‘"’?

1 Like

Yes is that not what I put? I don’t know how to type lol

1 Like

I can’t find what to type is it a ?

1 Like

Yes speech marks just like you’d do with a string

1 Like

Well, it gives a small red error thing image

1 Like

Try using the same speech marks as when you did print(“working”)

1 Like

Try this.

  if hit.Parent:FindFirstChild("Humanoid") then

Yes I don’t know why that error was there lol

Gives error. Workspace.Quest1_Part.Script:6: attempt to index nil with ‘PlayerGui’

Gonna try. 30charssssssssssssss