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

How can I change the color of a brick if someone has a keycard in his backpack?

Asked by
Tripyfy 28
6 years ago

If I give someone the keycard and he has it in the backpack I want a brick to change the color into red, and if nobody has the keycard change the brick color to green.

0
You are explaining stuff really bad, try to get us in your shoes we have no idea on what you are talking about. royee354 129 — 6y
0
Share your script what isn't working, we'll help you as possible! D3LTA_Y 72 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Do that like this:

local brick = script.Parent -- Verification brick that changes colors
local p = game.Players:GetPlayerFromCharacter(brick)
while true do
    wait()
    if p then
        if p.Backpack:FindFirstChild("Keycard") ~= nil then
            brick.BrickColor = Color3.fromRGB(0,255,0) -- Make it green
            wait(3)
            brick.BrickColor = Color3.fromRGB(255,0,0) -- Make it red
        end
    end
end

Something like that I believe.

0
I'm using the script and I gave myself the keycard and the color doesn't change :/ Tripyfy 28 — 6y
0
BrickColor.new() in lines 7 and 9? Try that. DeceptiveCaster 3761 — 6y
0
It doesn't work, also it marks the = in red like an error, I have brick.BrickColor.new() on both lines Tripyfy 28 — 6y
0
brick.BrickColor = BrickColor.new() DeceptiveCaster 3761 — 6y
Ad

Answer this question