I made a script and it seemed to be having errors identifying that a certain child in game.Players.(Plr Name).PlayerGui.(GuiName)
I decided to make a script in which had the same effect, just creating a new IntValue in which would have to be relocated from Workspace to “SpecialGui.” Will be explained in the script.
Script: Model Script - Pastebin.com
Either way, I’ve already tried looking around the internet and it seems that I’m at a loss.
What I’m trying to do is set it so that when a player clicks a model, the click function will fire, thus having the next section of code commence and change the values inside said Gui. The problem is the fact that the Gui is non-existent or at least that’s what the Output is showing.
“SpecialGui is not a valid member of PlayerGui” Is what appeared in the Output when I checked. I ran the script multiple times, along with removing the Instance.new(“”), leaving only the function to identify that the Gui actually exists. All it comes back with, is that it doesn’t exist.
I also made sure that the PlayerGui even exists first before having it try and find out that SpecialGui exists.
Use :WaitForChild instead of indexing directly.
The output reported back with;
Infinite yield possible on ‘Players.Spiritual_Guardian.PlayerGui:WaitForChild(“SpecialGui”)’
If the server is trying to put SpecialGui into the player’s PlayerGui, that won’t (shouldn’t) work. Can you do it on the client instead with RemoteEvents?
It wasn’t trying to put SpecialGui into the Player’s PlayerGui folder. It was trying to identify that the Gui actually exists and then place the “special” test value inside said Gui.
If the server is trying to do that, it won’t work. You need to do GUI manipulation on the client.
Not sure if it’s the right term. What I mean is any code relevant to GUIs should be on the client. Why do you need the server involved?
Well, it’s for in-game. It’s technically for an NPC.
So there’ll be a ClickDetector. Once the Player clicks the NPC, a function will be carried out to make a frame visible to the player. So, unknown if it’s supposed to be running through the server but that’s what I’m trying to accomplish here.
You can connect ClickDetector.MouseClick on the client through a LocalScript and do the GUI code there.
I was using a regular script. I assume I should try a local script? Should I also change the game.Players.PlayerAdded or keep it? I read in another post that if it’s between a local and regular script, it’ll change.
You have no reason to use PlayerAdded in the LocalScript, just use Players.LocalPlayer
to reference the current client.
I just tried putting print"1" in at the start of the script and it didn’t show.
I could give the original scripts to show what I already have?
Sorry, I didn’t get notifications because you were replying to yourself. Where’s the LocalScript? LocalScripts only run in certain places. Try putting the LocalScript inside StarterPlayerScripts and fix the references.
3 Likes
game.Workspace.Model.ClickDetector.LocalScript but I’ll go ahead and try that
Remember to mark my post as the solution if it worked!