Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Script on stringvalues and leaderstats won't work?

Asked by 2 years ago

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

Log in to vote
0
Answered by
PastDays 108
2 years ago

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?

0
The string values are stored in a folder in StarterGui and the LocalScript changing the the values is stored in each StringValue. Mystical_Un1verse 9 — 2y
0
And this script checking it is also local? If not then that would be why it's not working. PastDays 108 — 2y
0
It is a local script. Mystical_Un1verse 9 — 2y
Ad

Answer this question