Do they print anything in the output tab?
by chance I ask your game is for phones?
Yes, both before and after the function, but not in the function
It has support for phones, yes
Seems like this is a hard issue to solve, try using this script for other buttons?
You’re assuming that there’s already stuff loaded within the PlayerGui
, but chances are is that it has the potential to give back nil
, which is a non-existent value & you would attempting to index a variable that doesn’t exist just yet
Also, if there would be no errors within your script then you should’ve gotten none within your Output Tab as well cause indexing the PlayerGui
& recieving an error back is a pretty common thing & it wouldn’t make sense if you didn’t a singular one
What you’ll have to do, is assign several WaitForChild calls starting with the PlayerGui
, and considering how your script is sorted out, it’s gonna be a painful process on yielding each individual Instance
I would also consider using MouseButton1Down
instead, as MouseButton1Click
tends to behave strangely for some platforms
print("This is running")
local Plr = game.Players.LocalPlayer
local PlrGui = Plr:WaitForChild("PlayerGui")
print("Player GUI loaded")
local MainGui = PlrGui:WaitForChild("MainGUI")
local Main = MainGui:WaitForChild("PhoneMain")
local PhoneHUD = MainGui:WaitForChild("PhoneHUD")
local Menu = PhoneHUD:WaitForChild("Menu")
local Frame = Menu:WaitForChild("Frame")
local ImageButton = Frame:WaitForChild("ImageButton")
local Buttons = Menu:WaitForChild("Apps"):WaitForChild("Home"):WaitForChild("Apps")
local Cash = Buttons:WaitForChild("Cash")
local Button = Cash:WaitForChild("Button")
print("Everything else loaded")
Button.MouseButton1Down:Connect(function()
warn("Clicked, should work")
end)
Although there are helpful resources that avoids this process, as you can take a look ChipioIndustries’s “WaitForPath” Post that avoids this consistent method calling
In that case, a MouseButtonup or something like that, I don’t know how to write it well, I don’t speak English, I use a translator
Trying this with a different button in the same phone ui did not work for me either
Wait, are you testing the script using a computer or a phone?
good answer it opened my mind but do it like this:
local Menu = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGUI").PhoneMain
local MenuButton
local player = game.Players.Localplayer
local Buttons = Menu.Apps.Home.Apps
MenuButton = Menu.PhoneHUD.Menu.Frame.ImageButton
Buttons.Cash.Button.MouseButton1Click:Connect(function()
warn("HIE")
end)
so it is more optimized
Computer, In studio, also here is the full phone if this helps:
I don’t know why I put the player on, I’m sorry I’m not in the studio and I can’t test it and I don’t know if it’s okay
This compared to the original script is no way “optimized” than the other. This is literally the same thing except you assign a value to the MenuButton
variable at a later time.
That still doesn’t resolve the issue that PlayerGui
can in fact, return back nil
depending on the User’s Platform and how fast it can perform
Also, you’re indexing the LocalPlayer
after retrieving the PlayerGui
which does not make sense, please make your posts as contribute & effective as possible rather than just adding more nonsense to the mix here
Okay, maybe try inserting a local script in the Button instance with this code:
script.Parent.MouseButton1Click:Connect(function()
print("WORKS")
end)
You don’t see the answer I left read because I said sorry for putting the local player I didn’t know
copy now if you put it in guiyou’re on fire haha
Who would think of putting so many waitforchild in a script?
Scripts that involves using instances that has a possibility of not being inserted into the game by the time the script runs. @JackscarIitt has used his script correctly because there is a possibility that a big GUI has not finished loading all the instances needed by the time the local script runs.
I’d recommend researching more into the Player Containers Guide before attempting to take on problems that even you yourself, may struggle on or don’t have yet full knowledge about
I don’t mean it in an insult in any sort of way, but if your posts aren’t well educated enough then members are gonna struggle, and possible have to create relevant separate posts about why another portion of their script isn’t working due to a poorly-drawn solution that someone thought was the answer
@ItzMeZeus_IGotHacked Make sure to keep it between DM’s & keep track on topic & if the issue becomes a huge situation just simply flag the post, don’t turn it into a crowd attracter