StringVarNotUpdating

I ran a code in which a script in the starter gui catches a value of a string val inside a folder inside the workspace. The folder is named Transaction and the string var is named transactor.
The starting value of the string is “”.
Then i call a function inside of a local script

LocalPLayer = game.Players.LocalPlayer.Name
Str = game.Workspace.Transaction.Trasactor
Str.Value = ""
script.Parent.MouseButton1Click:Connect(function()
	Str.Value = LocalPLayer
	script.Lender.Disabled = false
end)

And inside of it there is a script called lender
it has this code

script.Parent.Parent.MouseButton1Click:Connect(function()
	wait(3)
	local Transactor = game.Workspace.Transaction.Trasactor
	local PlayerName = Transactor.Value
	print(PlayerName)
	local Model = game.Workspace:FindFirstChild(PlayerName)
	local Gumanoid = Model:WaitForChild("Humanoid")
	local Lolit = game.ReplicatedStorage["Classic Lolita Skirt"]:Clone()
	Lolit.Parent = game.Workspace
	Gumanoid:Equip(Lolit)
end)

I thought the output of print(PlayerName) will be my name but the output is just coming as blank.
And there is another error.

  07:46:40.801 - Players.pirospacepride1.PlayerGui.SHOP.ShopMenu.BackAccesories.SKIRTS.Buy Button.LocalScript.Lender:7: attempt to index nil with 'WaitForChild'
07:46:40.801 - Stack Begin
07:46:40.801 - Script 'Players.pirospacepride1.PlayerGui.SHOP.ShopMenu.BackAccesories.SKIRTS.Buy Button.LocalScript.Lender', Line 7
07:46:40.802 - Stack End

It will be very helpful if you try to find the problem.
Thank you.

the fact that ‘WaitForChild’ is nil, means that “Model” doesn’t exist to begin with
which means, the following line :

local Model = game.Workspace:FindFirstChild(PlayerName)

has not found the Player, or you should try print(Model.Name) to be sure it has actually found the player

1 Like

Instead of a string value you could use a object value which contains the location of anything.

So if you use ObjectValue instead of string value you could do.

game:GetService("Players"):GetPlayerFromCharacter(objValue.Value) 

on line 7

1 Like

So i updated it.
Theres still a problem.
I changed the string to object value.

local LocalPLayer = game.Players.LocalPlayer.Name
Model = game.Workspace:FindFirstChild(LocalPLayer)
print(Model.Name)
Humanoid = Model:WaitForChild("Humanoid")
print(Humanoid.BodyWidthScale.Value)
Str = game.Workspace.Transaction.Transacter

script.Parent.MouseButton1Click:Connect(function()
	Str.Value = Humanoid
	script.Lender.Disabled = false
end)

this is the local script.
And this is the script

script.Parent.Parent.MouseButton1Click:Connect(function()
	local transactor = game.Workspace.Transaction.Transacter.Value
	print(transactor.Name)
end)

its showing nil for transaction.

local LocalPlayer = game.Players.LocalPlayer.Name
Model = game.Workspace:FindFirstChild(LocalPlayer)

instead of looking for the character in the workspace you can just do

local LocalPlayer = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChild'Humanoid'

Sorry for the late response

I have already got the humanoid. My problem is the script not updating the Object-value.
I checked whether the script had the humanoid value and it had that. But when i made the code to take the vaalue into another script, the script picked up a nil value.

No the localscript only takes the humanoid and puts an objectvalue onto it. The script dosent accept the object Value. Why?

I know what your problem is

Filtering Enabled.

The video I’m about to show you is FE I recorded it myself. But, Localscript are client sided which in really basic terms only you can see that the objectvalue.Value = Humanoid. While the server says its nil.

https://streamable.com/uybid8

In this video it shows me entering a part local then I look at the server and its not there.

This video is a good understanding. However, if you want to learn more about FE then look up a few YouTube video’s so you can get what it mean.