I want to make it to where if you click a part, the gui would go away/ destroyed. My current script doesn't work. Here it is:
function onClicked(playerWhoClicked) local guiName = game.LocalPlayer.PlayerGui.GameName -- Game name gui wait(0.1) guiName:Destroy() end script.Parent.ClickDetector.MouseClick:connect(onClicked)
The error says:
**LocalPlayer is not a valid member of DataModel
Help?
First off, to use "LocalPlayer", you need to be looking in players. Example:
local player = game.Players.LocalPlayer -- NOT just game.LocalPlayer
Second of all, I do recommend making this work using remote events. However, here is what I believe you need to do
function onClicked(playerWhoClicked) local guiName = playerWhoClicked.PlayerGui.GameName -- Game name gui, assuming everything is spelled correctly if guiName ~= nil then -- just making sure it's there wait() -- There is no point of waiting 1/10 seconds, just give it a wait() so it catches up. guiName:Destroy() --now it's removed end -- an extra end is now added end script.Parent.ClickDetector.MouseClick:connect(onClicked)
LocalPlayer is a child of Players
Use game.Players.LocalPlayer instead.
LocalPlayer is not a valid member of DataModel like it says. It should be game.Players.LocalPlayer, not just game.LocalPlayer