Unable to use variables in directory

I’m having trouble making changes to a specific client, im getting the username from a textbox.text and finding if that playername exists, thats all fine my trouble is here ( local XS = game.Players.UserinfoEvent.PlayerGui.FailsGUI.Frame) where I am unable to find that player using the already set variables.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AddEvent = ReplicatedStorage.Fails:WaitForChild("Add")
local RemoveEvent = ReplicatedStorage.Fails:WaitForChild("Remove")
local Players = game:GetService("Players")
local XHandler = ReplicatedStorage.Fails:WaitForChild("XHandler") 



AddEvent.OnServerEvent:Connect(function(plr, UserinfoEvent, Status)
	

	local UserinfoEvent = script.Parent.Parent.FailSetter.Frame.User.Text

	local PlayerToFail = UserinfoEvent

	local DirectedPlayer = game.Players:FindFirstChild(PlayerToFail)


	local XS = game.Players.UserinfoEvent.PlayerGui.FailsGUI.Frame
	
	XS.X1.One.Value = true
	
	
	print(DirectedPlayer)
	
end)
1 Like

do

local XS = game.Players[UserinfoEvent].PlayerGui.FailsGUI.Frame

To solve this problem, you should change the line:

local XS = game.Players.UserinfoEvent.PlayerGui.FailsGUI.Frame

to:

local XS = DirectedPlayer.PlayerGui.FailsGUI.Frame

This way, you are accessing the player’s GUI that you are referencing through the DirectedPlayer variable, instead of trying to access directly through the “Players” property of “game”.

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