Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script on stringvalues and leaderstats won't work?

I have a script that when a leaderstat in a player is changed to a specific word, the value of the StringValue will change to the players name with the keyword. The problem is, there are two StringValues and they both have essentially the same script just with different keywords, and only one of them will work at a time so only one StringValue has a players name. I tried to make this explanation as least confusing as possible.

local namevalue = script.Parent

for i, plr in pairs(game.Players:GetPlayers()) do
	local findvalue = plr.leaderstats:FindFirstChild("StringValue")

	findvalue.Changed:Connect(function(NewValue)
		if findvalue.Value == "Keyword" then
			namevalue.Value = plr.Name
		else if findvalue.Value ~= "Keyword" then
				namevalue.Value = ""
			end
		end
	end)
end

1 answer

The script seems fine, A few questions:

Is this script run locally or on the server? Are the values changed from the client or the server?

3 comments

0

The string values are stored in a folder in StarterGui and the LocalScript changing the the values is stored in each StringValue.

0

And this script checking it is also local? If not then that would be why it's not working.

0

It is a local script.

This discussion is preserved as it was. New answers, comments, and votes are closed.