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

Set a boolvalue inside a certain player to true when they click a click detector?

I have a script the detects when a player click a clickdetector and then get their username. I also have a bool value that gets added into every player when they join. How would I set the bool value inside the player who clicked the part to true?

local button = script.Parent
local inUse = game.Workspace.Booth1:WaitForChild("InUse")
local Owner = game.Workspace.Booth1:WaitForChild("Owner")
local Label = script.Parent.Parent.SurfaceGui:WaitForChild("TextLabel")


button.MouseClick:Connect(function(player)
	
	if inUse.Value == false then
		inUse.Value = true
		Owner.Value = (player.Name)
		Label.Text = ("Claimed by " .. player.Name .. "!")
		
		
		-- change bool value of the player on line above ^^^^
		
	else
		
		print("Already being used!")
		

	end
end)

4 comments

0

What seems to be the problem...? I can't quite comprehend

0

Also which bool value are you talking about?

0

I dont know how to set the bool value of the specific player who clicked the clickDetecor to true. The bool value is just inside of every player, not listed in the script above.

0

What's the bool value's name and where is it located, e.g.. YourAverageMyth > BoolFolder > Bool

1 answer

✓ Accepted answer
local button = script.Parent
local inUse = game.Workspace.Booth1:WaitForChild("InUse")
local Owner = game.Workspace.Booth1:WaitForChild("Owner")
local Label = script.Parent.Parent.SurfaceGui:WaitForChild("TextLabel")


button.MouseClick:Connect(function(player)

-- I'm on my phone indentions are off 
local playerCharacter = player.Character

-- Assuming the bool is the character's child, edited it removed: player. ... 
local theBool = playerCharacter:FindFirstChild("TheBool")

    if inUse.Value == false then
        inUse.Value = true
        Owner.Value = (player.Name)
        Label.Text = ("Claimed by " .. player.Name .. "!")

-- There it is
theBool.Value = true


        -- change bool value of the player on line above ^^^^

    else

        print("Already being used!")


    end
end)

2 comments

0

This worked!! For some reason I had to replace player.Character with player.TheBool and remove playerCharacter from local theBool = player.playerCharacter:FindFirstChild("TheBool")

0

Oh wait I did a mistake on the local bool line it's just supposed to be playerCharacter:FindFirstChild.. But anyways glad i could help

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