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

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

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

✓ Accepted answer

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.

1 comment

0

Wow. I don't know how I made such an amazingly amateur error, but thanks for catching it!

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