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

Unable to find value in player?

Asked by 2 years ago

So, I'm making an in game ID card. In my game, there are 6 soul colors that are each represented by a number. There's also an integer value (created in another script) that's stored within the players character. It's called "Color." I'm trying to have the script find that value, and then change the color of a GUI frame to fit the persons chosen color on the ID card. It isn't working and I've tried a BUNCH of stuff.

local Player = game:GetService("Players")
local frame = Player.PlayerGui.IDCardGui:FindFirstChild("ColorFrame")

game.Players.PlayerAdded:Connect(function(player)
    print("Player added detected")
    player.CharacterAdded:Connect(function(character)
        print("color script started")
        local ColorValue = character:FindFirstChild("Color")
        if not ColorValue then return end
        print("color value found")
        if ColorValue == 1 then 
            print("color value is red")
            frame.BackgroundColor3 = Color3.fromHSV(0.666667, 0.333333, 1)
            print("color loaded!")
        end
    end)
end)

I've (obviously) tried to use prints to tell me what's working and what isn't, but absolutely none of them have shown up. Please bare with me, I don't usually work with Players.

How do I get the script to find the value and change the gui? Any help is appreciated!

0
Line 11: "ColorValue" -> "ColorValue.Value" 9mze 193 — 2y

1 answer

Log in to vote
0
Answered by
NykoVania 231 Moderation Voter
2 years ago

Does this print anything?

local Player = game:GetService("Players")
local frame = Player.PlayerGui.IDCardGui:FindFirstChild("ColorFrame")

game.Players.PlayerAdded:Connect(function(player)
    print("Player added detected")
    player.CharacterAdded:Connect(function(character)
        print("color script started")
        local ColorValue = character:FindFirstChild("Color")
            if not ColorValue then
            print("color value found")
        return
    end
        if ColorValue == 1 then 
            print("color value is red")
            frame.BackgroundColor3 = Color3.fromHSV(0.666667, 0.333333, 1)
            print("color loaded!")
        end
    end)
end)
0
Unfortunately it did not. thank you for your help though! I appreciate it NUR53_M45K 0 — 2y
Ad

Answer this question