local frame = game.StarterGui.changeBodyColorGui.Frame
local function onClick()
frame.Visible = true
end
script.Parent.MouseClick:Connect(onClick)
this is inside a click detector and i get no errors from the output, whats wrong?
local frame = game.StarterGui.changeBodyColorGui.Frame
local function onClick()
frame.Visible = true
end
script.Parent.MouseClick:Connect(onClick)
this is inside a click detector and i get no errors from the output, whats wrong?
Here's my code with an explanation.
script:FindFirstAncestorWhichIsA("ClickDetector").MouseClick:Connect(function(Player)
--[[
By using FindFirstAncestor you're looking through all the ancestors, aka 'Parent.Parent.Parent' but much shorter.
If you noticed 'function(Player)', that's a built-in argument to the connection, use that to your advantage.
Make sure this is a server-script & not a client-script. Make sure you're modifying it in the PlayerGui and not the StarterGui, the StarterGui is a service that allows you to modify the game GUIs much easier.
]]
Player:FindFirstChildWhichIsA("PlayerGui")["changeBodyColorGui"].Frame.Visible = true
end)
You're changing StarterGui, not PlayerGui
To change PlayerGui, just pass the player argument and reference PlayerGui from there
local function onClick(player)
player.PlayerGui.changeBodyColorGui.Frame = true
end
script.Parent.MouseClick:Connect(onClick)
oh, right thx, can't believe a forgot that
hold on, its not working
Any errors
no
Another thing is, you should not be using a click detector, for clicking a button, use a regular button, text button, image button OR don't use a local function.
script.Parent.MouseClick:Connect(function()
game.StarterGui.ScreenGui.Frame.Visible = false
end)
When dealing with frames, you always want a Click Detector to access the STARTERGUI because that's where everything is, if you're trying to get a certain item in someone's or on someone's screen that's where player gui comes in. You should probably use both but also don't forget that you should use a text button if it's a gui if it's not use a click detector.
why are you editing startergui
Why would you edit player gui if you can do starter gui, when a text button is clicked you don't edit player gui do you?
You edit PlayerGUI - playergui is a container in which guis from the server are to be cloned to the player, hence the name "PlayerGui"! You can read more on the developer hub
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
because you are changing startergui
wdym? I'm changing the frame
where is the script located