Well, script is not working... It is not in Local Script... And it is freaking me out so please help here is the script... I opened Developer Console and it says PlayerGui is not valid member of Part I dont know what did I do wrong... I freak myself when I do something so long and it is not working... Well I'm trying to get answer on this question very long... And also I think that PlayerGui hates me... xD Please help!
function onTouched(theplayer) theplayer.PlayerGui.ScreenGui.OBJECTIVE_1.Enabled = true end script.Parent.Touched:connect(onTouched)
So, you may have gotten an error... Which you did and obviously, I noticed that you are using the players character to find the playerGui??????
this may not work but will give you an idea VVV
function Touch(PlayersBodyPart) local BodyPart = PlayerBodyPart -- using a simpler variable local Character = BodyPart.Parent -- the players character if Character:FindFirstChild("Humanoid") then -- if players character exists.... local player = game:GetService("Players"):FindFirstChild(Character.Name) -- this should get the local player local GUI = player.PlayerGui.ScreenGui.OBJECTIVE_1 GUI.Enabled = true end end script.Parent.Touched:connect(Touch)
I'm pretty sure this won't work ^^ Because I don't know how to get localplayer from scripts but i used a good strategy, there is a good chance it will work... Anyways, cya
EDIT: I would put the script as a localscript in startergui
local part = workspace.Part -- must be your part local GUI = script.Parent.ScreenGui.OBJECTIVE_1 part.Touched:connect(function() if GUI.ClassName == "ScreenGui" then GUI.Enabled = true elseif GUI.ClassName == "Frame" then Gui.Visible = true end end
This should work ^ it is untested but i bet it works
I need to see what your gui and part are and then I can make it happen for sure
local plrName = nil local player = nil function onTouched(part) -- this is the part that touched the brick if (game.Players:FindFirstChild(part.Parent.Name)) then -- checks if part is a child of Player's Character plrName = part.Parent.Name -- sets 'plrName' to the Player's name who touched the brick player = game.Players:FindFirstChild(plrName) -- finds the Player in game.Players player.PlayerGui.ScreenGui.OBJECTIVE_1.Enabled = true end end script.Parent.Touched:connect(onTouched)
What you need to do is reference Players.
function onTouched(hit) If hit.Parent:FindFirstChild("Humanoid") then game.Players[hit.Parent.Name].PlayerGui.ScreenGui.OBJECTIVE_1.Enabled = true end end script.Parent.Touched:connect(onTouched)
If you don't, it will error on you
What you were doing is searching inside the part that touched the brick you want to be touched. So if your arm it it, it would search that