How to check visible at image, in the local script

Okay, I need to do the following, check if image(starterGui) has visible enabled, and if so, make boolValue(replicatedStorage), true. How to do it ?

if image.Visble == true then
       game.ReplicatedStorage.boolValue.Value = true
end

right??? Or am I not thinking this through enough?

Might need to put it in a loop but I think this is it

Unless he want’s to actively check it and the image’s visible property is constantly changing, I don’t think a loop is necessary for his purposes. Although he hasn’t really put that much information or context to the question.

It is correct, but the funny thing is that it should not be a local script… and you need to get starterGui(image) in a GLOBAL script not in a local one

Ok so you need to check if the image in starter gui is visible but you want to check it in a server-side script correct? And if it shows that the image is visible in the server-side script, you want to make a bool value in replicated storage turn true, right?

Just fact check me on this, I wanna make sure I’m understanding you correctly.

Yes, you read that right, I need this because I have a skill tree and I need to check if a skill is learned, then make boolValue true, for example to open some player’s skill.

The problem is that opening a skill is not a local script, so I need to check visibility, but not as a local script.

What you want to do in a situation like this where you have to transfer data from the client to the server or from the server to the client is set up a remote event to allow for this data transfer to occur. You need a data transfer because the server script cannot access the information of whether or not the image is visible due to the image being on the client side.

To do this;
Screenshot 2023-05-30 145322
Within the local script, you can have:

image = script.Parent
IVR = game.ServerScriptService.ImageVisibleHandler.ImageVisibleRetriever

if image.Visible == true then
	IVR:FireServer(image.Visible)
end

In the server script, you can have:

IVR = script.ImageVisibleRetriever
boolValue = game.ReplicatedStorage.boolValue

IVR.OnServerEvent:Connect(function(value)
	boolValue.Value = value
end)

This should work and solve your issue. Also, on a security-related side note, if you are trusting the client to tell you honorably whether or not the player has learned a skill, you should do this differently. Never trust the client. The client in this situation can edit the image’s visibility from their perspective without the server knowing, and then fool the server into thinking the image was made visible through intended and honorable means.

Have a great day, and if this doesn’t work let me know.

Thank you for your help, and you have a good day, if somewhere I do not understand I will write.

this will not work lmao

Not intended to work; just supposed to give a general idea of what I mean. Would you like me to spoonfeed him like a baby instead, or help him try to grow his skill by understanding concepts?

you should tell him what works you literally gave him misinformation lmao

Actual version that works:

local IVR = game:GetService("ReplicatedStorage").ImageVisibleRetriever
local Image = script.Parent
Image.Changed:Connect(function(Property)
	if Property == "Visible" then
		if Image.Visible then
			IVR:FireServer(true) -- Redudant.
		end
	end
end)
--
local IVR = game:GetService("ReplicatedStorage").ImageVisibleRetriever
local boolValue = game:GetService("ReplicatedStorage").boolValue

IVR.OnServerEvent:Connect(function(Player, Value)
	boolValue.Value = value
end)

He never said he wanted to actively check it. It seems as if he wanted to check it once and only once, and therefore .Changed or a loop to actively react to a change in the value of image’s Visible property is not required. It also seems that he wanted to check it as soon as the game ran.

As far as I know, you can’t learn a skill multiple times, so there is no need to see if it changes over time. The only real argument for adding a .Changed is that maybe the skill will be learned later on within the session after the game has been ran, but to me it looks like he just wants to check if the skill has ALREADY been learned before the player joined the game session.

Player, Value are the appropriate parameters instead of just Player, however as I said I was attempting to give him a general idea of what I was talking about, and not spoonfeed him.

Spoonfeed means giving whole code, you gave him not only a non working code but whole misinformation.

Misinformation? Buddy it’s not that deep. All I did was provide a general concept of how the code would go. Perhaps you should cry a little more. :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.