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

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

Asked by 3 years ago

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)

0
What seems to be the problem...? I can't quite comprehend xXLegendGamerz16Xx 231 — 3y
0
Also which bool value are you talking about? xXLegendGamerz16Xx 231 — 3y
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. YourAverageMyth 45 — 3y
0
What's the bool value's name and where is it located, e.g.. YourAverageMyth > BoolFolder > Bool xXLegendGamerz16Xx 231 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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)

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") YourAverageMyth 45 — 3y
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 xXLegendGamerz16Xx 231 — 3y
Ad

Answer this question