I’m trying to make a code save system for my game (Using datastore2 if that’s any help), and whenever i try and input a code that exists, I get an error saying ‘Unable to cast value to Object’
code
local CodeInput = script.Parent.Parent.CodeInput
script.Parent.MouseButton1Click:Connect(function()
local Code = CodeInput.Text
if Code == '' then
print("Code cannot be blank")
CodeInput.Text = 'Code cannot be blank'
else
for i,v in pairs(game.ReplicatedStorage.Codes:GetChildren()) do
if v.Name == Code then
game.ReplicatedStorage.RemoteEvents.CheckCodes:FireClient(Code, v)
else
script.Parent.Parent.CodeInput.Text = "Code does not exist"
end
end
end
end)
I don’t know what it means and I’ve tried searching for it online. Got nothing. please help. Thanks