This is the script which fires when I click on a part. However, there is no error but it prints nope which i assume means player:FindFirstChild(“Color” doesnt exist.
local part = script.Parent
local click = part.ClickDetector
local function onClicked(player)
local color = player:FindFirstChild("Color")
if color then
print("found color thingiemabob")
else
print("nope")
end
end
click.MouseClick:Connect(onClicked)
This is the code which gives the player an int value
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
local Value = Instance.new("IntValue",Character)
Value.Name = "Color"
Value.Value = 0
end)
end)
You create a Color inside the player’s character. When you click, you are not looking for it in the player's character itself, but in the player's instance. That was the problem.
In my reply, I gave you the answer on the first line lol.
However.
local part = script.Parent
local click = part.ClickDetector
local function onClicked(player)
local color = player.Character:FindFirstChild("Color")
if color then
print("found color thingiemabob")
else
print("nope")
end
end
click.MouseClick:Connect(onClicked)