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

Script that's supposed to make StringValue the name of the player who clicked a GUI doesn't work?

Asked by 6 years ago

This is my script. It is part of a revolutionary new checkout system that will be put into my new store game that will be part of my store group. What it is supposed to do is this: When "Yes" is clicked on a GUI, the StringValue in the Workspace (WorkerValue) becomes the name of the player who clicked it. However, it will not do so if a BoolValue in the Workspace equals true because that would mean that there is already someone working at that register. It does not work. There are no output errors, it plain old doesn't work. Why? Here is the script:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
    if game.Workspace.Value == true then
            script.Parent.Parent.Visible = true
            elseif game.Workspace.Value == false then
    for _, Player in pairs(game.Players:GetPlayers()) do
        game.Workspace.Value = true
        game.Workspace.WorkerValue = Player.Name
        end
    end
end)


1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

To alter the value of the BoolValue in workspace, you actually have to find the value (you can't just go game.Workspace.Value and expect it to know what value you are talking about). Also, when setting the WorkerValue value, you have to use .Value instead of just getting the instance:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Visible = false
    if game.Workspace["BoolValueNameHere"].Value == true then
            script.Parent.Parent.Visible = true
            elseif game.Workspace["BoolValueNameHere"].Value == false then
    for _, Player in pairs(game.Players:GetPlayers()) do
        game.Workspace["BoolValueNameHere"].Value = true
        game.Workspace.WorkerValue.Value = Player.Name
        end
    end
end)

Keep in mind, if you are using FilteringEnabled any server scripts will not be able to see any changes done to values through local scripts.

0
Wow. I don't know how I made such an amazingly amateur error, but thanks for catching it! sesamert16 31 — 6y
Ad

Answer this question